On 15/04/20(Wed) 09:26, Martin Pieuchot wrote:
> jca@ is currently building kernels with "-Wno-error=uninitialized" and
> reported a warning in ART in SP builds:
> 
> /usr/src/sys/net/art.c:256:10: warning: variable 'ndsr' is uninitialized when 
> used here [-Wuninitialized]
>                         dsr = ndsr;
>                               ^~~~
> /usr/src/sys/net/art.c:221:2: note: variable 'ndsr' is declared here
>         struct srp_ref          dsr, ndsr;
>         ^
> warning generated.
> 
> With a single CPU there's no need to save a reference and srp_leave()
> just does nothing.  In other words the warning above is harmless. 
> 
> The diff below prevents the false positive by turning srp_enter() into
> a static inline function, I find that nicer rather than clutter the code
> with #ifdef.

Now without typo, spotted by jca@ thanks!

Index: sys/srp.h
===================================================================
RCS file: /cvs/src/sys/sys/srp.h,v
retrieving revision 1.14
diff -u -p -r1.14 srp.h
--- sys/srp.h   31 Mar 2019 14:03:40 -0000      1.14
+++ sys/srp.h   15 Apr 2020 15:03:00 -0000
@@ -96,11 +96,17 @@ void                *srp_enter(struct srp_ref *, struc
 void           *srp_follow(struct srp_ref *, struct srp *);
 void            srp_leave(struct srp_ref *);
 #else /* MULTIPROCESSOR */
+
+static inline void *
+srp_enter(struct srp_ref *sr, struct srp *srp)
+{
+       return (srp->ref);
+}
+
 #define srp_swap(_srp, _v)             srp_swap_locked((_srp), (_v))
 #define srp_update(_gc, _srp, _v)      srp_update_locked((_gc), (_srp), (_v))
 #define srp_finalize(_v, _wchan)       ((void)0)
-#define srp_enter(_sr, _srp)           ((_srp)->ref)
-#define srp_follow(_sr, _srp)          ((_srp)->ref)
+#define srp_follow(_sr, _srp)          srp_enter(_sr, _srp)
 #define srp_leave(_sr)                 do { } while (0)
 #endif /* MULTIPROCESSOR */
 

Reply via email to