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/
This commit is contained in:
committed by
Alejandro Colomar
parent
7a286ec079
commit
39819143ea
@@ -3813,13 +3813,12 @@ static int
|
|||||||
nxt_unit_shm_open(nxt_unit_ctx_t *ctx, size_t size)
|
nxt_unit_shm_open(nxt_unit_ctx_t *ctx, size_t size)
|
||||||
{
|
{
|
||||||
int fd;
|
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)
|
#if (NXT_HAVE_MEMFD_CREATE || NXT_HAVE_SHM_OPEN)
|
||||||
char name[64];
|
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",
|
snprintf(name, sizeof(name), NXT_SHM_PREFIX "unit.%d.%p",
|
||||||
lib->pid, (void *) (uintptr_t) pthread_self());
|
lib->pid, (void *) (uintptr_t) pthread_self());
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user