Skip to content

Commit

Permalink
Fix off_t straggers (HDFGroup#4291)
Browse files Browse the repository at this point in the history
Convert off_t to HDoff_t (mainly for Windows):

* h5jam
* h5unjam
* chunk_info test
  • Loading branch information
derobins authored Mar 31, 2024
1 parent 203a95a commit 80fc855
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions test/chunk_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -2367,9 +2367,9 @@ test_chunk_address_with_userblock(hid_t fapl_id)
int data = -1;
int data_ub = -1;

if (HDlseek(fd, (off_t)(od.addresses[i]), SEEK_SET) < 0)
if (HDlseek(fd, (HDoff_t)(od.addresses[i]), SEEK_SET) < 0)
TEST_ERROR;
if (HDlseek(fd_ub, (off_t)(od_ub.addresses[i]), SEEK_SET) < 0)
if (HDlseek(fd_ub, (HDoff_t)(od_ub.addresses[i]), SEEK_SET) < 0)
TEST_ERROR;

if (HDread(fd, &data, sizeof(int)) != sizeof(int))
Expand Down
4 changes: 2 additions & 2 deletions tools/src/h5jam/h5jam.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ main(int argc, char *argv[])
hsize_t startub;
hsize_t where;
hsize_t newubsize;
off_t fsize;
HDoff_t fsize;
h5_stat_t sbuf;
h5_stat_t sbuf2;
int res;
Expand Down Expand Up @@ -253,7 +253,7 @@ main(int argc, char *argv[])
goto done;
}

fsize = (off_t)sbuf.st_size;
fsize = (HDoff_t)sbuf.st_size;

h5fid = HDopen(input_file, O_RDONLY);
if (h5fid < 0) {
Expand Down
12 changes: 6 additions & 6 deletions tools/src/h5jam/h5unjam.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ main(int argc, char *argv[])
{
hid_t ifile = H5I_INVALID_HID;
hid_t plist = H5I_INVALID_HID;
off_t fsize;
HDoff_t fsize;
hsize_t usize;
htri_t testval;
herr_t status;
Expand Down Expand Up @@ -306,9 +306,9 @@ copy_to_file(FILE *infid, FILE *ofid, ssize_t _where, ssize_t show_much)
{
static char buf[COPY_BUF_SIZE];
size_t how_much;
off_t where = (off_t)_where;
off_t to;
off_t from;
HDoff_t where = (HDoff_t)_where;
HDoff_t to;
HDoff_t from;
herr_t ret_value = 0;

/* nothing to copy */
Expand Down Expand Up @@ -349,8 +349,8 @@ copy_to_file(FILE *infid, FILE *ofid, ssize_t _where, ssize_t show_much)

/* Update positions/size */
how_much -= bytes_read;
from += (off_t)bytes_read;
to += (off_t)bytes_read;
from += (HDoff_t)bytes_read;
to += (HDoff_t)bytes_read;

/* Write nchars bytes to output file */
bytes_wrote = fwrite(buf, (size_t)1, bytes_read, ofid);
Expand Down

0 comments on commit 80fc855

Please sign in to comment.