Re: likely/unlikely usage validation

2024-05-29 Thread Dan Carpenter
On Wed, May 29, 2024 at 10:44:08AM +0200, Rasmus Villemoes wrote: > diff -u -p ./lib/lz4/lz4_decompress.c /tmp/nothing/lib/lz4/lz4_decompress.c > --- ./lib/lz4/lz4_decompress.c > +++ /tmp/nothing/lib/lz4/lz4_decompress.c > @@ -199,9 +199,6 @@ static FORCE_INLINE int LZ4_decompress_g >

Re: likely/unlikely usage validation

2024-05-29 Thread Dan Carpenter
On Tue, May 28, 2024 at 02:03:26PM +0200, Rasmus Villemoes wrote: > On 28/05/2024 12.37, Mateusz Guzik wrote: > > I misplaced a closing ) in a patch using unlikely() and broke the > > comparison, see [1] for context. > > > > The fix was: > > - if (unlikely(abs(count + amount)) >= bat

Re: likely/unlikely usage validation

2024-05-29 Thread Dan Carpenter
On Tue, May 28, 2024 at 02:51:33PM +0200, Rasmus Villemoes wrote: > Actually, perhaps coccinelle would be a simpler place to implement a > check like this. I think Coccinelle would work on code that you can't compile as well. Plus when you implement things in different ways, then you always find d

Re: likely/unlikely usage validation

2024-05-29 Thread Dan Carpenter
On Tue, May 28, 2024 at 12:37:23PM +0200, Mateusz Guzik wrote: > I misplaced a closing ) in a patch using unlikely() and broke the > comparison, see [1] for context. > > The fix was: > - if (unlikely(abs(count + amount)) >= batch) { > + if (unlikely(abs(count + amount)

Re: likely/unlikely usage validation

2024-05-29 Thread Rasmus Villemoes
On 28/05/2024 14.51, Rasmus Villemoes wrote: > Actually, perhaps coccinelle would be a simpler place to implement a > check like this. So I got curious and wrote a .cocci looking for this kind of pattern, and apart from the stuff found via grep there were only two more instances. The first is yet

Re: likely/unlikely usage validation

2024-05-28 Thread Rasmus Villemoes
On 28/05/2024 14.21, Mateusz Guzik wrote: > On Tue, May 28, 2024 at 2:03 PM Rasmus Villemoes > wrote: >> >> scripts/checkpatch.pl:# likely/unlikely comparisons similar to >> "(likely(foo) > 0)" >> >> So checkpatch should already have such a check, but running it on those >> two files doesn't catch

Re: likely/unlikely usage validation

2024-05-28 Thread Mateusz Guzik
On Tue, May 28, 2024 at 2:03 PM Rasmus Villemoes wrote: > > On 28/05/2024 12.37, Mateusz Guzik wrote: > > I misplaced a closing ) in a patch using unlikely() and broke the > > comparison, see [1] for context. > > > > The fix was: > > - if (unlikely(abs(count + amount)) >= batch) { >

Re: likely/unlikely usage validation

2024-05-28 Thread Rasmus Villemoes
On 28/05/2024 12.37, Mateusz Guzik wrote: > I misplaced a closing ) in a patch using unlikely() and broke the > comparison, see [1] for context. > > The fix was: > - if (unlikely(abs(count + amount)) >= batch) { > + if (unlikely(abs(count + amount) >= batch)) { > > Nei

likely/unlikely usage validation

2024-05-28 Thread Mateusz Guzik
I misplaced a closing ) in a patch using unlikely() and broke the comparison, see [1] for context. The fix was: - if (unlikely(abs(count + amount)) >= batch) { + if (unlikely(abs(count + amount) >= batch)) { Neither kernel build with W=1 nor C=1 (smatch) report the pro