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

two windows telnet.c compiler warnings #1225

Closed
bagder opened this Issue Jan 23, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@bagder
Member

bagder commented Jan 23, 2017

I did this

I looked at this windows build log showing these two compiler warnings

.\telnet.c(1455) : warning C4267: 'function' : conversion from 'size_t' to 'DWORD', possible loss of data
.\telnet.c(1474) : warning C4267: 'function' : conversion from 'size_t' to 'DWORD', possible loss of data

I expected the following

No warnings

curl/libcurl version

7.52.1 and current 7.53.0-dev in git master

operating system

Winsock

Suggested patch

curl-fix-telnet-warnings.patch, also inlined here:

--- a/lib/telnet.c
+++ b/lib/telnet.c
@@ -3,11 +3,11 @@
  *  Project                     ___| | | |  _ \| |
  *                             / __| | | | |_) | |
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
  * are also available at https://curl.haxx.se/docs/copyright.html.
  *
@@ -1414,11 +1414,11 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
     wait_timeout = 1000;
   }
 
   /* Keep on listening and act on events */
   while(keepon) {
-    const size_t buf_size = CURL_BUFSIZE(data->set.buffer_size);
+    const DWORD buf_size = (DWORD)CURL_BUFSIZE(data->set.buffer_size);
     waitret = WaitForMultipleObjects(obj_count, objs, FALSE, wait_timeout);
     switch(waitret) {
     case WAIT_TIMEOUT:
     {
       for(;;) {

@bagder bagder added the build label Jan 23, 2017

@jay

This comment has been minimized.

Member

jay commented Jan 24, 2017

👍

@bagder bagder closed this in d8a3aa7 Jan 24, 2017

@bagder

This comment has been minimized.

Member

bagder commented Jan 24, 2017

thanks!

peterpih pushed a commit to railsnewbie257/curl that referenced this issue Jan 24, 2017

telnet: fix windows compiler warnings
Thumbs-up-by: Jay Satiro

Closes curl#1225
@gvanem

This comment has been minimized.

Member

gvanem commented Mar 30, 2017

I should perhaps have made a new PR, but this fits here...

Another set of warnings (from clang-cl):

telnet.c(1427,21):  warning: comparison of constant 268435456 with expression of type 'CURLcode' is always false
      [-Wtautological-constant-out-of-range-compare]
          if(result == CURL_READFUNC_ABORT) {
             ~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~
telnet.c(1433,21):  warning: comparison of constant 268435457 with expression of type 'CURLcode' is always false
      [-Wtautological-constant-out-of-range-compare]
          if(result == CURL_READFUNC_PAUSE)
             ~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~
2 warnings generated.

That makes sense since CURL_LAST is < 0x10000000.

bagder added a commit that referenced this issue Mar 31, 2017

telnet: (win32) fix read callback return variable
telnet.c(1427,21): warning: comparison of constant 268435456 with
expression of type 'CURLcode' is always false

telnet.c(1433,21): warning: comparison of constant 268435457 with
expression of type 'CURLcode' is always false

Reported-by: Gisle Vanem
Bug: #1225 (comment)

bagder added a commit that referenced this issue Mar 31, 2017

telnet: (win32) fix read callback return variable
telnet.c(1427,21): warning: comparison of constant 268435456 with
expression of type 'CURLcode' is always false

telnet.c(1433,21): warning: comparison of constant 268435457 with
expression of type 'CURLcode' is always false

Reviewed-by: Jay Satiro
Reported-by: Gisle Vanem
Bug: #1225 (comment)

Closes #1374

@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.