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

3.3: compile time warnings #27

Open
kloczek opened this issue Aug 22, 2023 · 1 comment
Open

3.3: compile time warnings #27

kloczek opened this issue Aug 22, 2023 · 1 comment

Comments

@kloczek
Copy link

kloczek commented Aug 22, 2023

Looks like there are some compile time warning.
(I'm using gcc 13.2)

base64.c: In function 'encode_base64':
base64.c:44:7: warning: pointer targets in assignment from 'char *' to 'const unsigned char *' differ in signedness [-Wpointer-sign]
   44 |   end = (char *)data + length - 3;
      |       ^
base64.c:91:9: warning: pointer targets in assignment from 'unsigned char *' to 'char *' differ in signedness [-Wpointer-sign]
   91 |   *code = buf - n;
      |         ^
hts.c: In function 'main':
hts.c:286:5: warning: ignoring return value of 'daemon' declared with attribute 'warn_unused_result' [-Wunused-result]
  286 |     daemon (0, 1);
      |     ^~~~~~~~~~~~~
http.c: In function 'http_method':
http.c:45:23: warning: format '%d' expects argument of type 'int', but argument 3 has type 'ssize_t' {aka 'long int'} [-Wformat=]
   45 |       sprintf (str, "%d", length);
      |                      ~^   ~~~~~~
      |                       |   |
      |                       int ssize_t {aka long int}
      |                      %ld
http.c: In function 'parse_header':
http.c:329:11: warning: pointer targets in assignment from 'unsigned char *' to 'const char *' differ in signedness [-Wpointer-sign]
  329 |   h->name = data;
      |           ^
http.c:336:12: warning: pointer targets in assignment from 'unsigned char *' to 'const char *' differ in signedness [-Wpointer-sign]
  336 |   h->value = data;
      |            ^
http.c: In function 'http_parse_response':
http.c:506:35: warning: pointer targets in passing argument 1 of 'atoi' differ in signedness [-Wpointer-sign]
  506 |   response->major_version = atoi (data);
      |                                   ^~~~
      |                                   |
      |                                   unsigned char *
In file included from /usr/include/features.h:503,
                 from /usr/include/time.h:25,
                 from http.c:9:
/usr/include/stdlib.h:481:1: note: expected 'const char *' but argument is of type 'unsigned char *'
  481 | __NTH (atoi (const char *__nptr))
      | ^~~~~
http.c:519:35: warning: pointer targets in passing argument 1 of 'atoi' differ in signedness [-Wpointer-sign]
  519 |   response->minor_version = atoi (data);
      |                                   ^~~~
      |                                   |
      |                                   unsigned char *
/usr/include/stdlib.h:481:1: note: expected 'const char *' but argument is of type 'unsigned char *'
  481 | __NTH (atoi (const char *__nptr))
      | ^~~~~
http.c:532:33: warning: pointer targets in passing argument 1 of 'atoi' differ in signedness [-Wpointer-sign]
  532 |   response->status_code = atoi (data);
      |                                 ^~~~
      |                                 |
      |                                 unsigned char *
/usr/include/stdlib.h:481:1: note: expected 'const char *' but argument is of type 'unsigned char *'
  481 | __NTH (atoi (const char *__nptr))
      | ^~~~~
http.c:545:28: warning: pointer targets in assignment from 'unsigned char *' to 'const char *' differ in signedness [-Wpointer-sign]
  545 |   response->status_message = data;
      |                            ^
http.c: In function 'http_parse_request':
http.c:654:44: warning: pointer targets in passing argument 1 of 'http_string_to_method' differ in signedness [-Wpointer-sign]
  654 |   request->method = http_string_to_method (data, n - 1);
      |                                            ^~~~
      |                                            |
      |                                            unsigned char *
http.c:157:36: note: expected 'const char *' but argument is of type 'unsigned char *'
  157 | http_string_to_method (const char *method, size_t n)
      |                        ~~~~~~~~~~~~^~~~~~
http.c:674:16: warning: pointer targets in assignment from 'unsigned char *' to 'const char *' differ in signedness [-Wpointer-sign]
  674 |   request->uri = data;
      |                ^
http.c:701:34: warning: pointer targets in passing argument 1 of 'atoi' differ in signedness [-Wpointer-sign]
  701 |   request->major_version = atoi (data);
      |                                  ^~~~
      |                                  |
      |                                  unsigned char *
/usr/include/stdlib.h:481:1: note: expected 'const char *' but argument is of type 'unsigned char *'
  481 | __NTH (atoi (const char *__nptr))
      | ^~~~~
http.c:714:34: warning: pointer targets in passing argument 1 of 'atoi' differ in signedness [-Wpointer-sign]
  714 |   request->minor_version = atoi (data);
      |                                  ^~~~
      |                                  |
      |                                  unsigned char *
/usr/include/stdlib.h:481:1: note: expected 'const char *' but argument is of type 'unsigned char *'
  481 | __NTH (atoi (const char *__nptr))
      | ^~~~~
htc.c: In function 'main':
htc.c:411:5: warning: ignoring return value of 'daemon' declared with attribute 'warn_unused_result' [-Wunused-result]
  411 |     daemon (0, 1);
      |     ^~~~~~~~~~~~~
tunnel.c: In function 'tunnel_in_setsockopts':
tunnel.c:164:19: warning: pointer targets in passing argument 5 of 'getsockopt' differ in signedness [-Wpointer-sign]
  164 |                   &n);
      |                   ^~
      |                   |
      |                   int *
In file included from /usr/include/netinet/in.h:23,
                 from /usr/include/netdb.h:27,
                 from port/netdb_.h:10,
                 from tunnel.c:11:
/usr/include/sys/socket.h:257:46: note: expected 'socklen_t * restrict' {aka 'unsigned int * restrict'} but argument is of type 'int *'
  257 |                        socklen_t *__restrict __optlen) __THROW;
      |                        ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
tunnel.c: In function 'tunnel_out_setsockopts':
tunnel.c:198:21: warning: pointer targets in passing argument 5 of 'getsockopt' differ in signedness [-Wpointer-sign]
  198 |                     &n);
      |                     ^~
      |                     |
      |                     int *
/usr/include/sys/socket.h:257:46: note: expected 'socklen_t * restrict' {aka 'unsigned int * restrict'} but argument is of type 'int *'
  257 |                        socklen_t *__restrict __optlen) __THROW;
      |                        ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
tunnel.c:225:17: warning: pointer targets in passing argument 5 of 'getsockopt' differ in signedness [-Wpointer-sign]
  225 |                 &n);
      |                 ^~
      |                 |
      |                 int *
/usr/include/sys/socket.h:257:46: note: expected 'socklen_t * restrict' {aka 'unsigned int * restrict'} but argument is of type 'int *'
  257 |                        socklen_t *__restrict __optlen) __THROW;
      |                        ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
tunnel.c:254:21: warning: pointer targets in passing argument 5 of 'getsockopt' differ in signedness [-Wpointer-sign]
  254 |                     &n);
      |                     ^~
      |                     |
      |                     int *
/usr/include/sys/socket.h:257:46: note: expected 'socklen_t * restrict' {aka 'unsigned int * restrict'} but argument is of type 'int *'
  257 |                        socklen_t *__restrict __optlen) __THROW;
      |                        ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
tunnel.c:303:17: warning: pointer targets in passing argument 5 of 'getsockopt' differ in signedness [-Wpointer-sign]
  303 |                 &n);
      |                 ^~
      |                 |
      |                 int *
/usr/include/sys/socket.h:257:46: note: expected 'socklen_t * restrict' {aka 'unsigned int * restrict'} but argument is of type 'int *'
  257 |                        socklen_t *__restrict __optlen) __THROW;
      |                        ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
tunnel.c: In function 'tunnel_read':
tunnel.c:934:48: warning: pointer targets in passing argument 3 of 'tunnel_read_request' differ in signedness [-Wpointer-sign]
  934 |   if (tunnel_read_request (tunnel, &req, tunnel->buf, &len) <= 0)
      |                                          ~~~~~~^~~~~
      |                                                |
      |                                                char *
tunnel.c:808:37: note: expected 'unsigned char *' but argument is of type 'char *'
  808 |                      unsigned char *buf, size_t *length)
      |                      ~~~~~~~~~~~~~~~^~~
tunnel.c: In function 'tunnel_accept':
tunnel.c:1115:68: warning: pointer targets in passing argument 3 of 'accept' differ in signedness [-Wpointer-sign]
 1115 |       s = accept (tunnel->server_socket, (struct sockaddr *)&addr, &len);
      |                                                                    ^~~~
      |                                                                    |
      |                                                                    int *
/usr/include/sys/socket.h:307:42: note: expected 'socklen_t * restrict' {aka 'unsigned int * restrict'} but argument is of type 'int *'
  307 |                    socklen_t *__restrict __addr_len);
      |                    ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
tunnel.c:1177:1: warning: format '%d' expects argument of type 'int', but argument 3 has type 'size_t' {aka 'long unsigned int'} [-Wformat=]
 1177 | "HTTP/1.1 200 OK\r\n"
      | ^~~~~~~~~~~~~~~~~~~~~
......
 1191 |                        tunnel->content_length + 1);
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                               |
      |                                               size_t {aka long unsigned int}
tunnel.c:1183:19: note: format string is defined here
 1183 | "Content-Length: %d\r\n"
      |                  ~^
      |                   |
      |                   int
      |                  %ld
@larsbrinkhoff
Copy link
Owner

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants