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

Fix compiler warnings with CURL_DISABLE_VERBOSE_STRINGS and DEBUGBUILD #7528

Closed
wants to merge 1 commit into from

Conversation

@MAntoniak
Copy link
Contributor

@MAntoniak MAntoniak commented Aug 2, 2021

  • socks.c : warning C4100: 'lineno': unreferenced formal parameter
  • mbedtls.c: warning C4189: 'port': local variable is initialized but not referenced
  • schannel.c: warning C4189: 'hostname': local variable is initialized but not referenced
lib/socks.c Outdated
, int lineno
#endif
enum connect_t state,
int lineno
Copy link
Member

@bagder bagder Aug 4, 2021

Why do you think passing on the line number unconditionally is a good idea? Why is that needed to silence warnings?

Copy link
Contributor Author

@MAntoniak MAntoniak Aug 4, 2021

I do not consider it necessary to remove the alert. I think this is the easier way to get rid of this warning. Of course, you can also add an appropriate condition for the presence of an additional argument to the function. Which version will be better?

Copy link
Member

@bagder bagder Aug 8, 2021

I imagined something like this for the socks.c fix:

diff --git a/lib/socks.c b/lib/socks.c
index 91c4223a5..0bc0cfb76 100644
--- a/lib/socks.c
+++ b/lib/socks.c
@@ -97,28 +97,29 @@ int Curl_blockread_all(struct Curl_easy *data,   /* transfer */
   }
   return result;
 }
 #endif
 
-#ifndef DEBUGBUILD
-#define sxstate(x,y) socksstate(x,y)
-#else
+#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
+#define DEBUG_AND_VERBOSE
 #define sxstate(x,y) socksstate(x,y, __LINE__)
+#else
+#define sxstate(x,y) socksstate(x,y)
 #endif
 
 
 /* always use this function to change state, to make debugging easier */
 static void socksstate(struct Curl_easy *data,
                        enum connect_t state
-#ifdef DEBUGBUILD
+#ifdef DEBUG_AND_VERBOSE
                        , int lineno
 #endif
 )
 {
   struct connectdata *conn = data->conn;
   enum connect_t oldstate = conn->cnnct.state;
-#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
+#ifdef DEBUG_AND_VERBOSE
   /* synced with the state list in urldata.h */
   static const char * const statename[] = {
     "INIT",
     "SOCKS_INIT",
     "SOCKS_SEND",
@@ -144,11 +145,11 @@ static void socksstate(struct Curl_easy *data,
     /* don't bother when the new state is the same as the old state */
     return;
 
   conn->cnnct.state = state;
 
-#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
+#ifdef DEBUG_AND_VERBOSE
   infof(data,
         "SXSTATE: %s => %s conn %p; line %d",
         statename[oldstate], statename[conn->cnnct.state], conn,
         lineno);
 #endif

Copy link
Contributor Author

@MAntoniak MAntoniak Aug 11, 2021

Done.

@jay jay added the build label Aug 10, 2021
…BUGBUILD flags are active.

- socks.c : warning C4100: 'lineno': unreferenced formal parameter (co-authored by Daniel Stenberg)
- mbedtls.c: warning C4189: 'port': local variable is initialized but not referenced
- schannel.c: warning C4189: 'hostname': local variable is initialized but not referenced
bagder added a commit that referenced this issue Aug 14, 2021
For when CURL_DISABLE_VERBOSE_STRINGS and DEBUGBUILD flags are both
active.

- socks.c : warning C4100: 'lineno': unreferenced formal parameter
  (co-authored by Daniel Stenberg)

- mbedtls.c: warning C4189: 'port': local variable is initialized but
  not referenced

- schannel.c: warning C4189: 'hostname': local variable is initialized
  but not referenced

Cloes #7528
@bagder
Copy link
Member

@bagder bagder commented Aug 14, 2021

Thanks!

@bagder
Copy link
Member

@bagder bagder commented Aug 14, 2021

Closed by fd84db6

@bagder bagder closed this Aug 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants