Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a few issues with error reporting during sec2 reads/writes #4794

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/H5FDsec2.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,15 +700,16 @@ H5FD__sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU
int myerrno = errno;
time_t mytime = time(NULL);

#ifndef H5_HAVE_PREADWRITE
offset = HDlseek(file->fd, 0, SEEK_CUR);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since pread doesn't change the file offset, this HDlseek call ends up resetting the file offset that gets printed out on errors.

#endif

HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL,
"file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, "
"error message = '%s', buf = %p, total read size = %llu, bytes this sub-read = %llu, "
"bytes actually read = %llu, offset = %llu",
ctime(&mytime), file->filename, file->fd, myerrno, strerror(myerrno), buf,
(unsigned long long)size, (unsigned long long)bytes_in,
(unsigned long long)bytes_read, (unsigned long long)offset);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the printing out of bytes_read since it will always be -1 in this case, so casting it to unsigned long long and printing it out just gives misleading output.

"error message = '%s', buf = %p, total read size = %zu, bytes this sub-read = %llu, "
"offset = %llu",
ctime(&mytime), file->filename, file->fd, myerrno, strerror(myerrno), buf, size,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to %zu for size rather than casting to unsigned long long.

(unsigned long long)bytes_in, (unsigned long long)offset);
} /* end if */

if (0 == bytes_read) {
Expand Down Expand Up @@ -810,15 +811,16 @@ H5FD__sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN
int myerrno = errno;
time_t mytime = time(NULL);

#ifndef H5_HAVE_PREADWRITE
offset = HDlseek(file->fd, 0, SEEK_CUR);
#endif

HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
"file write failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, "
"error message = '%s', buf = %p, total write size = %llu, bytes this sub-write = "
"%llu, bytes actually written = %llu, offset = %llu",
ctime(&mytime), file->filename, file->fd, myerrno, strerror(myerrno), buf,
(unsigned long long)size, (unsigned long long)bytes_in,
(unsigned long long)bytes_wrote, (unsigned long long)offset);
"error message = '%s', buf = %p, total write size = %zu, bytes this sub-write = "
"%llu, offset = %llu",
ctime(&mytime), file->filename, file->fd, myerrno, strerror(myerrno), buf, size,
(unsigned long long)bytes_in, (unsigned long long)offset);
} /* end if */

assert(bytes_wrote > 0);
Expand Down
Loading