Unverified Commit 5bd8c389 authored by Marcel Raad's avatar Marcel Raad
Browse files

examples: fix -Wformat warnings

When size_t is not a typedef for unsigned long (as usually the case on
Windows), GCC emits -Wformat warnings when using lu and lx format
specifiers with size_t. Silence them with explicit casts to
unsigned long.

Closes https://github.com/curl/curl/pull/2721
parent ba1dbd78
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -45,11 +45,11 @@ void dump(const char *text,
    width = 0x40;

  fprintf(stream, "%s, %10.10lu bytes (0x%8.8lx)\n",
          text, size, size);
          text, (unsigned long)size, (unsigned long)size);

  for(i = 0; i<size; i += width) {

    fprintf(stream, "%4.4lx: ", i);
    fprintf(stream, "%4.4lx: ", (unsigned long)i);

    if(!nohex) {
      /* hex not disabled, show it */
+1 −1
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ int main(void)
     * Do something nice with it!
     */

    printf("%lu bytes retrieved\n", chunk.size);
    printf("%lu bytes retrieved\n", (unsigned long)chunk.size);
  }

  /* cleanup curl stuff */
+2 −2
Original line number Diff line number Diff line
@@ -72,11 +72,11 @@ void dump(const char *text, int num, unsigned char *ptr, size_t size,
    width = 0x40;

  fprintf(stderr, "%d %s, %lu bytes (0x%lx)\n",
          num, text, size, size);
          num, text, (unsigned long)size, (unsigned long)size);

  for(i = 0; i<size; i += width) {

    fprintf(stderr, "%4.4lx: ", i);
    fprintf(stderr, "%4.4lx: ", (unsigned long)i);

    if(!nohex) {
      /* hex not disabled, show it */
+4 −4
Original line number Diff line number Diff line
@@ -52,11 +52,11 @@ void dump(const char *text, unsigned char *ptr, size_t size,
    width = 0x40;

  fprintf(stderr, "%s, %lu bytes (0x%lx)\n",
          text, size, size);
          text, (unsigned long)size, (unsigned long)size);

  for(i = 0; i<size; i += width) {

    fprintf(stderr, "%4.4lx: ", i);
    fprintf(stderr, "%4.4lx: ", (unsigned long)i);

    if(!nohex) {
      /* hex not disabled, show it */
@@ -181,11 +181,11 @@ static int server_push_callback(CURL *parent,
  curl_easy_setopt(easy, CURLOPT_WRITEDATA, out);

  fprintf(stderr, "**** push callback approves stream %u, got %lu headers!\n",
          count, num_headers);
          count, (unsigned long)num_headers);

  for(i = 0; i<num_headers; i++) {
    headp = curl_pushheader_bynum(headers, i);
    fprintf(stderr, "**** header %lu: %s\n", i, headp);
    fprintf(stderr, "**** header %lu: %s\n", (unsigned long)i, headp);
  }

  headp = curl_pushheader_byname(headers, ":path");
+2 −2
Original line number Diff line number Diff line
@@ -73,11 +73,11 @@ void dump(const char *text, int num, unsigned char *ptr, size_t size,
    width = 0x40;

  fprintf(stderr, "%d %s, %lu bytes (0x%lx)\n",
          num, text, size, size);
          num, text, (unsigned long)size, (unsigned long)size);

  for(i = 0; i<size; i += width) {

    fprintf(stderr, "%4.4lx: ", i);
    fprintf(stderr, "%4.4lx: ", (unsigned long)i);

    if(!nohex) {
      /* hex not disabled, show it */
Loading