Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed ‘length’ may be used in Array.prototype.pop(). #741

Merged
merged 2 commits into from
Jun 29, 2024

Conversation

xeioex
Copy link
Contributor

@xeioex xeioex commented Jun 21, 2024

When building by GCC with -O3 and -flto flags the following warning was reported:
src/njs_array.c: In function ‘njs_array_prototype_pop’: src/njs_array.c:1009:8: error: ‘length’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
1009 | if (length == 0) {
| ^

Returning a specific code in njs_value_to_number() helps GCC to infer that there are only 2 return values are possible and both of them are handled.

Checklist

Before creating a PR, run through this checklist and mark each as complete:

  • I have read the CONTRIBUTING document
  • If applicable, I have added tests that prove my fix is effective or that my feature works
  • If applicable, I have checked that any relevant tests pass after adding my changes

@xeioex xeioex requested a review from VadimZhestikov June 21, 2024 00:30
xeioex added 2 commits June 21, 2024 17:57
When building by GCC with -O3 and -flto flags the following
warning was reported:
src/njs_array.c: In function ‘njs_array_prototype_pop’:
src/njs_array.c:1009:8: error: ‘length’ may be used uninitialized in
this function [-Werror=maybe-uninitialized]
1009 | if (length == 0) {
     |     ^

Returning a specific code in njs_value_to_number() helps GCC
to infer that there are only 2 return values are possible and
both of them are handled.
When building by GCC 13 with -O3 and -flto flags the following
warning was reported:
In function ‘njs_utf8_decode’,
inlined from ‘njs_text_encoder_encode_into’ at
src/njs_encoding.c:214:14:
src/njs_utf8.c:191:42: error: ‘ctx.codepoint’ may be used
uninitialized [-Werror=maybe-uninitialized]
 191 |         ctx->codepoint = (ctx->codepoint << 6) | (c & 0x3F);
@xeioex xeioex merged commit 8c7ade4 into nginx:master Jun 29, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants