Message ID | 20240601175853.GY52987@frogsfrogsfrogs (mailing list archive) |
---|---|
State | Accepted, archived |
Headers | show |
Series | [v2] xfs_repair: detect null buf passed to duration | expand |
> diff --git a/repair/progress.h b/repair/progress.h > index 0b06b2c4f43f..c09aa69413ac 100644 > --- a/repair/progress.h > +++ b/repair/progress.h > @@ -38,7 +38,7 @@ extern void summary_report(void); > extern int set_progress_msg(int report, uint64_t total); > extern uint64_t print_final_rpt(void); > extern char *timestamp(struct xfs_mount *mp, int end, int phase, char *buf); > -extern char *duration(time_t val, char *buf); > +char *duration(time_t val, char *buf) __attribute__((nonnull(2))); Once nonnull() is used here, shouldn't we also set -Wnonnull to CFLAGS? Please don't take it as a review, it's just a question that came to my mind as I don't fully understand the implications of using nonnull here. Carlos
On Mon, Jun 03, 2024 at 02:42:20PM +0200, Carlos Maiolino wrote: > > > diff --git a/repair/progress.h b/repair/progress.h > > index 0b06b2c4f43f..c09aa69413ac 100644 > > --- a/repair/progress.h > > +++ b/repair/progress.h > > @@ -38,7 +38,7 @@ extern void summary_report(void); > > extern int set_progress_msg(int report, uint64_t total); > > extern uint64_t print_final_rpt(void); > > extern char *timestamp(struct xfs_mount *mp, int end, int phase, char *buf); > > -extern char *duration(time_t val, char *buf); > > +char *duration(time_t val, char *buf) __attribute__((nonnull(2))); > > Once nonnull() is used here, shouldn't we also set -Wnonnull to CFLAGS? Already set via -Wall, at least if you're using gcc 12.2: -Wnonnull Warn about passing a null pointer for arguments marked as requiring a non-null value by the "nonnull" function attribute. -Wnonnull is included in -Wall and -Wformat. It can be disabled with the -Wno-nonnull option. https://git.kernel.org/pub/scm/fs/xfs/xfsprogs-dev.git/tree/include/builddefs.in?h=for-next#n113 > Please don't take it as a review, it's just a question that came to my mind as I don't fully > understand the implications of using nonnull here. <nod> --D > Carlos >
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
On Mon, Jun 03, 2024 at 09:14:46AM GMT, Darrick J. Wong wrote: > On Mon, Jun 03, 2024 at 02:42:20PM +0200, Carlos Maiolino wrote: > > > > > diff --git a/repair/progress.h b/repair/progress.h > > > index 0b06b2c4f43f..c09aa69413ac 100644 > > > --- a/repair/progress.h > > > +++ b/repair/progress.h > > > @@ -38,7 +38,7 @@ extern void summary_report(void); > > > extern int set_progress_msg(int report, uint64_t total); > > > extern uint64_t print_final_rpt(void); > > > extern char *timestamp(struct xfs_mount *mp, int end, int phase, char *buf); > > > -extern char *duration(time_t val, char *buf); > > > +char *duration(time_t val, char *buf) __attribute__((nonnull(2))); > > > > Once nonnull() is used here, shouldn't we also set -Wnonnull to CFLAGS? > > Already set via -Wall, at least if you're using gcc 12.2: > > -Wnonnull > Warn about passing a null pointer for arguments marked as > requiring a non-null value by the "nonnull" function > attribute. > > -Wnonnull is included in -Wall and -Wformat. It can be > disabled with the -Wno-nonnull option. Ok, thanks for letting me know :) feel free to add: Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> > > https://git.kernel.org/pub/scm/fs/xfs/xfsprogs-dev.git/tree/include/builddefs.in?h=for-next#n113 > > > Please don't take it as a review, it's just a question that came to my mind as I don't fully > > understand the implications of using nonnull here. > > <nod> > > --D > > > Carlos > >
diff --git a/repair/progress.h b/repair/progress.h index 0b06b2c4f43f..c09aa69413ac 100644 --- a/repair/progress.h +++ b/repair/progress.h @@ -38,7 +38,7 @@ extern void summary_report(void); extern int set_progress_msg(int report, uint64_t total); extern uint64_t print_final_rpt(void); extern char *timestamp(struct xfs_mount *mp, int end, int phase, char *buf); -extern char *duration(time_t val, char *buf); +char *duration(time_t val, char *buf) __attribute__((nonnull(2))); extern int do_parallel; #define PROG_RPT_INC(a,b) if (ag_stride && prog_rpt_done) (a) += (b)