title: Re Legacy code : format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘long unsigned int’ [-Wformat]
body: <p>I often try to build a lot of old simulator and disk and tape archive tools, with recent GCC. Some errors are easy to fix, but I'm not so good a programmer.</p>
  
  <p>I get :</p>
  
  <blockquote>
    <p>itstar.c: In function ‘addfiles’:<br>
    itstar.c:194:4: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long unsigned int’ [-Wformat]<br>
    itstar.c:194:4: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘long unsigned int’ [-Wformat]</p>
  </blockquote>
  
  <p>from this code fragment :</p>
  
  <pre><code>/* add files to a DUMP tape */
  /* output buffer must have been initialized with resetbuf() */
  static void addfiles(int argc,char **argv)
  {
      int c=argc;
      char **v=argv;
  
      while(c--) {
          addfile(argc,argv,*v++);
      }
      if(verify)
          printf("Approximately %d.%d' of tape used\n",count/bpi/12,
              (count*10/bpi/12)%10);
  }
  </code></pre>
  
  <p>Where line 194 is the third from last, beginning with printf.  </p>
  
  <p>The file is itstar.c, from tapetools, code <a href="https://sourceforge.net/p/tapetools/code/HEAD/tree/itstar/itstar.c" rel="nofollow">here</a>.</p>
  
  <p>It builds despite the warning, but I prefer to know how to prevent it,<br>
  so the result is more efficient and there is less chance of data corruption.  </p>
  
  <p>Please, what have I missed, and need to change ?    </p>
  
  <p>Thank you in advance.</p>