Closed Bug 2075958 Opened 1 month ago Closed 8 days ago

[build failure] clang 23: static variables "set but not used" in httpserv.c, selfserv.c, javascript.c

Categories

(NSS :: Build, defect, P1)

x86_64
FreeBSD

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: guillaume-mozilla, Assigned: jschanck)

References

Details

(Whiteboard: [nss-nofx])

Attachments

(1 external file)

Steps to reproduce

Building the 3.130 tarball with BUILD_OPT=1, clang 23.1.1 as a compiler

Actual results

httpserv.c:58:25: error: variable 'lm' set but not used [-Werror,-Wunused-but-set-global]
httpserv.c:141:12: error: variable 'threadCount' set but not used [-Werror,-Wunused-but-set-global]

Expected results

Compilation was expected not to stop on this error.

It seems unused-but-set-global became default with clang 23, thus this error probably went unnoticed before it.

threadCount only gets used in an assert (which is discarded on optimized builds),
lm is used in the VLOG macro (same discarding).

#ifdef PR_LOGGING may be the solution to lm,
#if defined(DEBUG) || defined(FORCE_PR_ASSERT) for threadCount

OS: Unspecified → FreeBSD
Hardware: Unspecified → x86_64

There were errors as well on:

  • cmd/selfserv/selfserv.c: lm, opsPerSec, previousOps
    (lm: as in httpserv.c, both others: as for threadCount)
  • cmd/signtool/javascript.c: jartree
    (I simply removed it, it seemed here "for future use")

Here is my full source fixer, allowing NSS to compile:

for f in cmd/httpserv/httpserv.c cmd/selfserv/selfserv.c
do
        filtrer "$f" sed -E -e '/threadCount[^A-Z]|opsPerSec|previousOps/{
i\
#if defined(DEBUG) || defined(FORCE_PR_ASSERT)
a\
#endif
}' -e '/LogModule.*lm|lm.*LogModule/{
i\
#ifdef PR_LOGGING
a\
#endif
}'
done
filtrer cmd/signtool/javascript.c grep -v jartree

(filtrer() is my in-place filtering shell function, filtrer $f sed … working like a sed -i)

Summary: [build failure] clang 23: static variables "set but not used" in httpserv.c → [build failure] clang 23: static variables "set but not used" in httpserv.c, selfserv.c, javascript.c
Depends on: 1793424, 1998094, 2066591
Assignee: nobody → jschanck
Severity: -- → S3
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Priority: -- → P1
Whiteboard: [nss-nofx]
Attachment #9672511 - Attachment description: WIP: Bug 2075958 - Fix -Wunused-but-set-global errors with clang 23 in httpserv, selfserv and signtool → Bug 2075958 - Fix -Wunused-but-set-global errors with clang 23 in httpserv, selfserv and signtool
Blocks: 2088397
Attachment #9672511 - Attachment description: Bug 2075958 - Fix -Wunused-but-set-global errors with clang 23 in httpserv, selfserv and signtool → Bug 2075958 - Fix -Wunused-but-set-global errors with clang 23 in httpserv and selfserv

Pushed by nkulatova@mozilla.com:
https://hg.mozilla.org/projects/nss/rev/c732fc8dc551
Fix -Wunused-but-set-global errors with clang 23 in httpserv and selfserv r=crypto-reviewers,jschanck

Status: ASSIGNED → RESOLVED
Closed: 8 days ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: