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

clang-cl warnings in 'vtls/bearssl.c' #13290

Closed
gvanem opened this issue Apr 5, 2024 · 0 comments
Closed

clang-cl warnings in 'vtls/bearssl.c' #13290

gvanem opened this issue Apr 5, 2024 · 0 comments
Labels

Comments

@gvanem
Copy link
Contributor

gvanem commented Apr 5, 2024

I did this

Used clang-cl ver. 17.0.1 to compile libcurl with -DUSE_BEARSSL=1, gave these warnings for lib/vtls/bearssl.c:

vtls/bearssl.c(160,7): warning: variable 'p' may be uninitialized when used here [-Wconditional-uninitialized]
  160 |       p += pushed;
      |       ^
vtls/bearssl.c(123,25): note: initialize the variable 'p' to silence this warning
  123 |   const unsigned char *p;
      |                         ^
      |                          = NULL
vtls/bearssl.c(156,11): warning: variable 'n' may be uninitialized when used here [-Wconditional-uninitialized]
  156 |     while(n) {
      |           ^
vtls/bearssl.c(125,11): note: initialize the variable 'n' to silence this warning
  125 |   size_t n, i, pushed;
      |           ^
      |            = 0

My CFLAGS contained -Wall.

With this diff:

--- a/vtls/bearssl.c 2024-02-17 11:19:39
+++ b/vtls/bearssl.c 2024-04-01 06:41:42
@@ -120,9 +120,9 @@
   br_x509_pkey *pkey;
   FILE *fp = 0;
   unsigned char buf[BUFSIZ];
-  const unsigned char *p;
+  const unsigned char *p = NULL;
   const char *name;
-  size_t n, i, pushed;
+  size_t n = 0, i, pushed;

there are no warnings.

I expected the following

No warnings.

curl/libcurl version

curl 8.7.2-DEV (x86_64-pc-win32) libcurl/8.7.2-DEV built from git master today.

operating system

Windows-10

@bagder bagder added the TLS label Apr 5, 2024
bagder pushed a commit that referenced this issue Apr 5, 2024
"variables may be uninitialized when used"

Fixes #13290
@bagder bagder closed this as completed in 59bfc53 Apr 5, 2024
vszakats pushed a commit to vszakats/curl that referenced this issue Apr 7, 2024
"variables may be uninitialized when used"

Fixes curl#13290
Closes curl#13297
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants