From: Douglas Bagnall Date: Fri, 29 Dec 2023 02:27:08 +0000 (+1300) Subject: ndr: mark invalid pull ndr_flags as unlikely X-Git-Tag: tdb-1.4.11~1806 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4face258dee93dcd01dce71fcb7448b285ff4860;p=thirdparty%2Fsamba.git ndr: mark invalid pull ndr_flags as unlikely This might have little effect, but sometimes we see primatives like ndr_pull_uint32() taking a few percent of the CPU time, and this is in all those functions. Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett BUG: https://bugzilla.samba.org/show_bug.cgi?id=15574 --- diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h index 70dd01e49a6..03d1aead01a 100644 --- a/librpc/ndr/libndr.h +++ b/librpc/ndr/libndr.h @@ -367,7 +367,7 @@ enum ndr_compression_alg { }; #define NDR_PULL_CHECK_FLAGS(ndr, ndr_flags) do { \ - if ((ndr_flags) & ~(NDR_SCALARS|NDR_BUFFERS)) { \ + if (unlikely((ndr_flags) & ~(NDR_SCALARS|NDR_BUFFERS))) { \ return ndr_pull_error(ndr, NDR_ERR_FLAGS, "Invalid pull struct ndr_flags 0x%"PRI_NDR_FLAGS_TYPE, ndr_flags); \ } \ } while (0)