* 1 if EOF has been reached, 0 otherwise.
***************************************************************************
*/
-int sa_fread(int ifd, void *buffer, int size, int mode)
+int sa_fread(int ifd, void *buffer, size_t size, int mode)
{
- int n;
+ ssize_t n;
if ((n = read(ifd, buffer, size)) < 0) {
fprintf(stderr, _("Error while reading system activity file: %s\n"),
int read_record_hdr(int ifd, void *buffer, struct record_header *record_hdr,
struct file_header *file_hdr, int arch_64, int endian_mismatch)
{
- if (sa_fread(ifd, buffer, file_hdr->rec_size, SOFT_SIZE))
+ if (sa_fread(ifd, buffer, (size_t) file_hdr->rec_size, SOFT_SIZE))
/* End of sa data file */
return 1;
for (j = 0; j < (nr_value * act[p]->nr2); j++) {
sa_fread(ifd, (char *) act[p]->buf[curr] + j * act[p]->msize,
- act[p]->fsize, HARD_SIZE);
+ (size_t) act[p]->fsize, HARD_SIZE);
}
}
else if (nr_value > 0) {
* Note: If msize was smaller than fsize,
* then it has been set to fsize in check_file_actlst().
*/
- sa_fread(ifd, act[p]->buf[curr], act[p]->fsize * nr_value * act[p]->nr2, HARD_SIZE);
+ sa_fread(ifd, act[p]->buf[curr],
+ (size_t) act[p]->fsize * (size_t) nr_value * (size_t) act[p]->nr2, HARD_SIZE);
}
else {
/* nr_value == 0: Nothing to read */
SREALLOC(buffer, char, file_magic->header_size);
/* Read sa data file standard header and allocate activity list */
- sa_fread(*ifd, buffer, file_magic->header_size, HARD_SIZE);
+ sa_fread(*ifd, buffer, (size_t) file_magic->header_size, HARD_SIZE);
/*
* Data file header size (file_magic->header_size) may be greater or
* smaller than FILE_HEADER_SIZE. Remap the fields of the file header
for (i = 0; i < file_hdr->sa_act_nr; i++, fal++) {
/* Read current file_activity structure from file */
- sa_fread(*ifd, buffer, file_hdr->act_size, HARD_SIZE);
+ sa_fread(*ifd, buffer, (size_t) file_hdr->act_size, HARD_SIZE);
/*
* Data file_activity size (file_hdr->act_size) may be greater or
* smaller than FILE_ACTIVITY_SIZE. Remap the fields of the file's structure
n = (previous_format == FORMAT_MAGIC_2171 ? FILE_HEADER_SIZE_2171
: hdr_size);
SREALLOC(buffer, char, n);
- sa_fread(fd, buffer, n, HARD_SIZE);
+ sa_fread(fd, buffer, (size_t) n, HARD_SIZE);
/* Upgrade file_header structure */
upgrade_file_header(buffer, file_hdr, previous_format,
for (k = 0; k < act[p]->nr2; k++) {
sa_fread(fd,
(char *) act[p]->buf[0] + (j * act[p]->nr2 + k) * act[p]->msize,
- ofal->size, HARD_SIZE);
+ (size_t) ofal->size, HARD_SIZE);
}
}
}
else if (act[p]->nr_ini > 0) {
- sa_fread(fd, act[p]->buf[0], ofal->size * act[p]->nr_ini * act[p]->nr2, HARD_SIZE);
+ sa_fread(fd, act[p]->buf[0],
+ (size_t) ofal->size * (size_t) act[p]->nr_ini * (size_t) act[p]->nr2,
+ HARD_SIZE);
}
nr_struct = act[p]->nr_ini;
* 1 if end of file has been reached, 0 otherwise.
***************************************************************************
*/
-int sa_read(void *buffer, int size)
+int sa_read(void *buffer, size_t size)
{
- int n;
+ ssize_t n;
while (size) {
(size_t) act[p]->fsize * (size_t) act[p]->nr_ini * (size_t) act[p]->nr2);
}
}
- if (sa_read(act[p]->buf[curr], act[p]->fsize * act[p]->nr[curr] * act[p]->nr2)) {
+ if (sa_read(act[p]->buf[curr],
+ (size_t) act[p]->fsize * (size_t) act[p]->nr[curr] * (size_t) act[p]->nr2)) {
print_read_error(END_OF_DATA_UNEXPECTED);
}
}