mlyszczek commented on code in PR #6605: URL: https://github.com/apache/incubator-nuttx/pull/6605#discussion_r921937388
########## fs/mount/fs_procfs_mount.c: ########## @@ -256,11 +261,39 @@ static int blocks_entry(FAR const char *mountpoint, /* Generate blocks list one line at a time */ - mount_sprintf(info, "%6lu %10" PRIuOFF " %10" PRIuOFF +#ifdef CONFIG_LIBC_LONG_LONG + mount_sprintf(info, "%6zu %10" PRIuOFF " %10" PRIuOFF " %10" PRIuOFF " %s\n", statbuf->f_bsize, statbuf->f_blocks, statbuf->f_blocks - statbuf->f_bavail, statbuf->f_bavail, mountpoint); +#else +# if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG) + if (statbuf->f_blocks > ULONG_MAX) + { + fwarn("Detected unsigned overflow in 'Blocks', upper word = %lu\n", + (uint32_t)(statbuf->f_blocks >> 32)); + } + + if ((statbuf->f_blocks - statbuf->f_bavail) > ULONG_MAX) + { + fwarn("Detected unsigned overflow in 'Used', upper word = %lu\n", + (uint32_t)((statbuf->f_blocks - statbuf->f_bavail) >> 32)); + } + + if (statbuf->f_bavail > ULONG_MAX) + { + fwarn("Detected unsigned overflow in 'Avail', upper word = %lu\n", Review Comment: As explained in my previous comment - I think I would use fprintf(stderr) in all of these cases. If something should fail - it should fail as soon as possible and as loud as possible. fwarn() is not particularly loud - you need to enable like 5 Kconfig options to get that. And if someone sees strange output in df, I don't think their first though will be to enable fwarn() and they will simply waste time. The only concern is wasting flash memory, but that can be optimized by doing ``` #define OVERFLOW_FMT "Detected unsigned overflow in '%s', upper word = %lu\n" fprintf(stderr, OVERFLOW_FMT, "Blocks", ...); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org