Re: [PATCH] xfs_repair: detect null buf passed to duration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 31, 2024 at 01:10:39PM -0700, Darrick J. Wong wrote:
> I think this is a false negative since all callers are careful not to
> pass in a null pointer.

Yes.

> Unfortunately the compiler cannot detect that
> since this isn't a static function and complains.  Fix this by adding an
> explicit null check.

Can you try adding a __attribute__((nonnull(2))) to the declaration like
this?

diff --git a/repair/progress.h b/repair/progress.h
index 0b06b2c4f..c09aa6941 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)




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux