From 523516579 at qq.com Sun Mar 1 06:27:23 2026 From: 523516579 at qq.com (Weixie Cui) Date: Sun, 1 Mar 2026 14:27:23 +0800 Subject: [PATCH] socketutils: e is alway not NULL here because cache is static Message-ID: From: Weixie Cui Signed-off-by: Weixie Cui --- src/socketutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/socketutils.c b/src/socketutils.c index d3a3b9283..9416c7082 100644 --- a/src/socketutils.c +++ b/src/socketutils.c @@ -54,7 +54,7 @@ static const char * get_sockaddr_by_inode_cached(const unsigned long inode) { const cache_entry *const e = &cache[inode & CACHE_MASK]; - return (e && inode == e->inode) ? e->details : NULL; + return inode == e->inode ? e->details : NULL; } static bool -- 2.39.5 (Apple Git-154) From ldv at strace.io Sun Mar 1 12:46:01 2026 From: ldv at strace.io (Dmitry V. Levin) Date: Sun, 1 Mar 2026 14:46:01 +0200 Subject: [PATCH] socketutils: e is alway not NULL here because cache is static In-Reply-To: References: Message-ID: <20260301124601.GA22902@strace.io> On Sun, Mar 01, 2026 at 02:27:23PM +0800, Weixie Cui wrote: > From: Weixie Cui > > Signed-off-by: Weixie Cui > --- > src/socketutils.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/socketutils.c b/src/socketutils.c > index d3a3b9283..9416c7082 100644 > --- a/src/socketutils.c > +++ b/src/socketutils.c > @@ -54,7 +54,7 @@ static const char * > get_sockaddr_by_inode_cached(const unsigned long inode) > { > const cache_entry *const e = &cache[inode & CACHE_MASK]; > - return (e && inode == e->inode) ? e->details : NULL; > + return inode == e->inode ? e->details : NULL; > } The cache is indeed static and therefore is initialized with zeroes. -- ldv From 523516579 at qq.com Sun Mar 1 14:23:32 2026 From: 523516579 at qq.com (Weixie Cui) Date: Sun, 1 Mar 2026 22:23:32 +0800 Subject: [PATCH] socketutils: e is alway not NULL here because cache is static In-Reply-To: References: Message-ID: From: Weixie Cui The cache is zeros. But e = &cache[inode & CACHE_MASK], e is address of one of cache item. e is alway not NULL.