Re: likely/unlikely usage validation
Rasmus Villemoes <[email protected]> Wed, 29 May 2024 10:44:08 +0200
| Newsgroups | org.kernel.vger.smatch |
|---|---|
| Message-ID | <[email protected]> |
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 another harmless != 0 thing, the second is
pretty convoluted but probably ok:
diff -u -p ./drivers/net/ethernet/google/gve/gve_rx_dqo.c
/tmp/nothing/drivers/net/ethernet/google/gve/gve_rx_dqo.c
--- ./drivers/net/ethernet/google/gve/gve_rx_dqo.c
+++ /tmp/nothing/drivers/net/ethernet/google/gve/gve_rx_dqo.c
@@ -813,8 +813,6 @@ static int gve_rx_dqo(struct napi_struct
/* Append to current skb if one exists. */
if (rx->ctx.skb_head) {
- if (unlikely(gve_rx_append_frags(napi, buf_state,
buf_len, rx,
- priv)) != 0) {
goto error;
}
return 0;
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
do {
s = *ip++;
length += s;
- } while (likely(endOnInput
- ? ip < iend - RUN_MASK
- : 1) & (s == 255));
if ((safeDecode)
&& unlikely((uptrval)(op) +
Rasmus