google / google/woff2

Possibly a false warning but can't hurt to initialize these 2 variables

Open
#132 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
1.8k
Forks
228
PR merge metrics
No merged PRs in 30d

Description

Compiling the code using -Weverything, clang c++ gives this warning:

./src/woff2_dec.cc:1215:39: warning: variable 'priv_length' may be uninitialized when used here [-Wconditional-uninitialized]
src_offset = Round4(priv_offset + priv_length);
^~~~~~~~~~~
./src/woff2_dec.cc:1095:23: note: initialize the variable 'priv_length' to silence this warning
uint32_t priv_length;
^
= 0
./src/woff2_dec.cc:1205:39: warning: variable 'meta_length' may be uninitialized when used here [-Wconditional-uninitialized]
src_offset = Round4(meta_offset + meta_length);
^~~~~~~~~~~
./src/woff2_dec.cc:1081:23: note: initialize the variable 'meta_length' to silence this warning
uint32_t meta_length;
^
= 0

Changing line 1081 as follows:

uint32_t meta_length = 0;

and line 1095 as follows:

uint32_t priv_length = 0;

silences this warning.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.