diff options
author | Andrew Clayton <andrew@digital-domain.net> | 2022-06-11 01:55:12 +0100 |
---|---|---|
committer | Andrew Clayton <andrew@digital-domain.net> | 2022-06-15 21:16:19 +0100 |
commit | 0a9ef7d023b96c6a0aad370be93d7f7d7009ed83 (patch) | |
tree | 91d6187463b7a0dcc4b734fab42d126b17cc4db0 | |
parent | 6a8081d71e805b12d0f7fd32ce72d60babadfc85 (diff) | |
download | unit-archive/unreadVariable.tar.gz unit-archive/unreadVariable.tar.bz2 |
Unit: Don't needlessly set lib in nxt_unit_shm_open().archive/unreadVariable
As was pointed out by the cppcheck[0] static code analysis utility, lib
was being set in nxt_unit_shm_open() regardless of platform when in fact
it's only used when (NXT_HAVE_MEMFD_CREATE || NXT_HAVE_SHM_OPEN).
Move the variable declaration & definition to be within the
#if (NXT_HAVE_MEMFD_CREATE || NXT_HAVE_SHM_OPEN)
block.
[0]: https://cppcheck.sourceforge.io/
-rw-r--r-- | src/nxt_unit.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/nxt_unit.c b/src/nxt_unit.c index f183ac6e..adfb4cb4 100644 --- a/src/nxt_unit.c +++ b/src/nxt_unit.c @@ -3812,13 +3812,12 @@ static int nxt_unit_shm_open(nxt_unit_ctx_t *ctx, size_t size) { int fd; - nxt_unit_impl_t *lib; - - lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); #if (NXT_HAVE_MEMFD_CREATE || NXT_HAVE_SHM_OPEN) + nxt_unit_impl_t *lib; char name[64]; + lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); snprintf(name, sizeof(name), NXT_SHM_PREFIX "unit.%d.%p", lib->pid, (void *) (uintptr_t) pthread_self()); #endif |