summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_unit.c
diff options
context:
space:
mode:
authorAndrew Clayton <andrew@digital-domain.net>2022-06-16 02:00:58 +0100
committerAlejandro Colomar <alx.manpages@gmail.com>2022-06-22 00:30:44 +0200
commit39819143ea891b752e5f1f6c6101d0861fb18850 (patch)
treef4f8b4331dce6507f512cdcc62497dbaea315827 /src/nxt_unit.c
parent7a286ec0797df4530eeee6f463ae00b86463084b (diff)
downloadunit-39819143ea891b752e5f1f6c6101d0861fb18850.tar.gz
unit-39819143ea891b752e5f1f6c6101d0861fb18850.tar.bz2
Unit: avoided needlessly setting lib in nxt_unit_shm_open().
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/
Diffstat (limited to 'src/nxt_unit.c')
-rw-r--r--src/nxt_unit.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/nxt_unit.c b/src/nxt_unit.c
index 4be09061..9baa680f 100644
--- a/src/nxt_unit.c
+++ b/src/nxt_unit.c
@@ -3813,13 +3813,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)
char name[64];
+ nxt_unit_impl_t *lib;
+ 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