Skip to content

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

Description

@gvanem

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions