Skip to content

Conversation

@mmatuska
Copy link
Contributor

Motivation and Context

The compilation on FreeBSD i386 is broken.

Description

Incorrect printf specifier in mmap_seek.c
Missing cast to atomic_add_64

How Has This Been Tested?

Compilation on FreeBSD i386 and amd64

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Quality assurance (non-breaking change which makes the code more robust against bugs)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

tests/zfs-tests/cmd/mmap_seek.c: use correct printf specifier
module/zfs/vdev.c: vdev_clear(): correctly cast argument to atomic_add_64()

Signed-off-by: Martin Matuska <[email protected]>
Comment on lines +58 to 60
fprintf(stderr, "lseek(fd, %jd, SEEK_%s) = %jd (expected %jd)",
offset, (whence == SEEK_DATA ? "DATA" : "HOLE"),
seek_offset, expect_offset);
Copy link
Member

Choose a reason for hiding this comment

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

Formally I think %jd is uintmax_t, which might be bigger than off_t.

Copy link
Contributor Author

@mmatuska mmatuska Jan 2, 2026

Choose a reason for hiding this comment

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

What is then the correct solution? I followed the guidelines in the linux off_t(3type) manpage

Linux manpage for off_t(3type):

To print a value of an integer type that doesn't have a length modifier, it should be converted to intmax_t or uintmax_t by an explicit cast.

Reference: https://man7.org/linux/man-pages/man3/off_t.3type.html

           "off_t max       %20jd %16jx\n" /* try PRIdMAX if %jd unsupported */

Reference: https://www.pixelbeat.org/programming/gcc/int_types/

Copy link
Contributor

Choose a reason for hiding this comment

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

As I understand it using %jd is the preferred solution, and it's what we've done in at least one other place (e.g. in tests/zfs-tests/cmd/clonefile.c). This looks good to me.

freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this pull request Jan 2, 2026
@mmatuska mmatuska requested a review from amotin January 3, 2026 22:23
@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Code Review Needed Ready for review and testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants