shithub: sox

Download patch

ref: 8571a527440a5ae5fef0cc5ac49cb129a9d82d4b
parent: f596a1a4a7abe3f5d2ca338cdc53e81f369092c3
author: Ulrich Klauer <ulrich@chirlu.de>
date: Mon Jan 2 03:41:44 EST 2012

More PRIuPTR/PRIu64 cases

Use PRIuPTR or PRIu64 when outputting size_t or uint64_t values,
respectively.

--- a/src/cvsd.c
+++ b/src/cvsd.c
@@ -611,7 +611,7 @@
         lsx_debug("  time      %s", ctime(&hdr.Unixtime)); /* ctime generates lf */
         lsx_debug("  usender   %u", hdr.Usender);
         lsx_debug("  ureceiver %u", hdr.Ureceiver);
-        lsx_debug("  length    %lu", (unsigned long)hdr.Length);
+        lsx_debug("  length    %" PRIuPTR, hdr.Length);
         lsx_debug("  srate     %u", hdr.Srate);
         lsx_debug("  days      %u", hdr.Days);
         lsx_debug("  custom1   %u", hdr.Custom1);
--- a/src/flanger.c
+++ b/src/flanger.c
@@ -154,8 +154,8 @@
       f->delay_buf_length - 2.,
       3 * M_PI_2);  /* Start the sweep at minimum delay (for mono at least) */
 
-  lsx_debug("delay_buf_length=%lu lfo_length=%lu\n",
-      (unsigned long)f->delay_buf_length, (unsigned long)f->lfo_length);
+  lsx_debug("delay_buf_length=%" PRIuPTR " lfo_length=%" PRIuPTR "\n",
+      f->delay_buf_length, f->lfo_length);
 
   return SOX_SUCCESS;
 }
--- a/src/formats_i.c
+++ b/src/formats_i.c
@@ -81,7 +81,7 @@
     if (!ft->signal.length)
       ft->signal.length = calculated_length;
     else if (num_samples != calculated_length)
-      lsx_warn("`%s': file header gives the total number of samples as %u but file length indicates the number is in fact %u", ft->filename, (unsigned)num_samples, (unsigned)calculated_length); /* FIXME: casts */
+      lsx_warn("`%s': file header gives the total number of samples as %" PRIu64 " but file length indicates the number is in fact %" PRIu64, ft->filename, num_samples, calculated_length);
   }
 
   if (sox_precision(ft->encoding.encoding, ft->encoding.bits_per_sample))
--- a/src/libsox.c
+++ b/src/libsox.c
@@ -94,11 +94,11 @@
 
     if (!info.arch)
     {
-        snprintf(arch, sizeof(arch), "%u%u%u%u %u%u %u%u %c %s",
-            (unsigned)sizeof(char), (unsigned)sizeof(short),
-            (unsigned)sizeof(long), (unsigned)sizeof(off_t),
-            (unsigned)sizeof(float), (unsigned)sizeof(double),
-            (unsigned)sizeof(int *), (unsigned)sizeof(int (*)(void)),
+        snprintf(arch, sizeof(arch),
+            "%" PRIuPTR "%" PRIuPTR "%" PRIuPTR "%" PRIuPTR
+            " %" PRIuPTR "%" PRIuPTR " %" PRIuPTR "%" PRIuPTR " %c %s",
+            sizeof(char), sizeof(short), sizeof(long), sizeof(off_t),
+            sizeof(float), sizeof(double), sizeof(int *), sizeof(int (*)(void)),
             MACHINE_IS_BIGENDIAN ? 'B' : 'L',
             (info.flags & sox_version_have_threads) ? "OMP" : "");
         arch[sizeof(arch) - 1] = 0;
--- a/src/mp3-util.h
+++ b/src/mp3-util.h
@@ -168,7 +168,7 @@
     memcpy(p->mp3_buffer, mad_stream.this_frame, leftover);
     read = fread(p->mp3_buffer + leftover, (size_t) 1, p->mp3_buffer_size - leftover, fp);
     if (read <= 0) {
-      lsx_debug("got exact duration by scan to EOF (frames=%lu leftover=%lu)", (unsigned long)frames, (unsigned long)leftover);
+      lsx_debug("got exact duration by scan to EOF (frames=%" PRIuPTR " leftover=%" PRIuPTR ")", frames, leftover);
       break;
     }
     for (; !depadded && padding < read && !p->mp3_buffer[padding]; ++padding);
@@ -216,7 +216,7 @@
           }
         if ((frames = xing_frames(p, mad_stream.anc_ptr, mad_stream.anc_bitlen))) {
           p->mad_timer_multiply(&time, (signed long)frames);
-          lsx_debug("got exact duration from XING frame count (%lu)", (unsigned long)frames);
+          lsx_debug("got exact duration from XING frame count (%" PRIuPTR ")", frames);
           break;
         }
       }
--- a/src/mp3.c
+++ b/src/mp3.c
@@ -546,7 +546,7 @@
     memcpy(p->mp3_buffer, p->Stream.this_frame, leftover);
     read = fread(p->mp3_buffer + leftover, (size_t) 1, p->mp3_buffer_size - leftover, (FILE*)ft->fp);
     if (read <= 0) {
-      lsx_debug("seek failure. unexpected EOF (frames=%lu leftover=%lu)", (unsigned long)p->FrameCount, (unsigned long)leftover);
+      lsx_debug("seek failure. unexpected EOF (frames=%" PRIuPTR " leftover=%" PRIuPTR ")", p->FrameCount, leftover);
       break;
     }
     for (; !depadded && padding < read && !p->mp3_buffer[padding]; ++padding);
@@ -556,7 +556,7 @@
     while (sox_true) {  /* Decode frame headers */
       static unsigned short samples;
       p->Stream.error = MAD_ERROR_NONE;
-      
+
       /* Not an audio frame */
       if (p->mad_header_decode(&p->Frame.header, &p->Stream) == -1) {
         if (p->Stream.error == MAD_ERROR_BUFLEN)
@@ -745,7 +745,7 @@
     num_samples = 0;
   }
   p->lame_set_num_samples(p->gfp, (unsigned long)num_samples);
-  lsx_debug("updated MP3 TLEN to %ld samples", (unsigned long)num_samples);
+  lsx_debug("updated MP3 TLEN to %" PRIu64 " samples", num_samples);
 
   new_size = p->lame_get_id3v2_tag(p->gfp, buffer, id3v2_size);
 
@@ -768,7 +768,7 @@
     fseeko(fp, (off_t)0, SEEK_SET);
     /* Overwrite the Id3v2 tag (this time TLEN should be accurate) */
     if (fwrite(buffer, id3v2_size, 1, fp) != 1) {
-      lsx_debug("Rewrote Id3v2 tag (%d bytes)", id3v2_size);
+      lsx_debug("Rewrote Id3v2 tag (%" PRIuPTR " bytes)", id3v2_size);
     }
   }
 
@@ -886,7 +886,7 @@
   p->lame_set_in_samplerate(p->gfp,(int)ft->signal.rate);
   p->lame_set_out_samplerate(p->gfp,(int)ft->signal.rate);
 
-  
+
   if (!LSX_DLFUNC_IS_STUB(p, id3tag_init))
     write_comments(ft);
 
--- a/src/sphere.c
+++ b/src/sphere.c
@@ -145,7 +145,7 @@
   lsx_writes(ft, "   1024\n");
 
   if (samples) {
-    sprintf(buf, "sample_count -i %lu\n", (unsigned long)samples);
+    sprintf(buf, "sample_count -i %" PRIu64 "\n", samples);
     lsx_writes(ft, buf);
   }
 
--- a/src/stretch.c
+++ b/src/stretch.c
@@ -174,11 +174,11 @@
     p->fade_coefs[0] = 1.0;
 
   lsx_debug("start: (factor=%g segment=%g shift=%g overlap=%g)\nstate=%d\n"
-      "segment=%lu\nindex=%lu\nishift=%lu\noindex=%lu\noshift=%lu\noverlap=%lu",
+      "segment=%" PRIuPTR "\nindex=%" PRIuPTR "\n"
+      "ishift=%" PRIuPTR "\noindex=%" PRIuPTR "\n"
+      "oshift=%" PRIuPTR "\noverlap=%" PRIuPTR,
       p->factor, p->window, p->shift, p->fading, p->state,
-      (unsigned long)p->segment, (unsigned long)p->index,
-      (unsigned long)p->ishift, (unsigned long)p->oindex,
-      (unsigned long)p->oshift, (unsigned long)p->overlap);
+      p->segment, p->index, p->ishift, p->oindex, p->oshift, p->overlap);
 
   return SOX_SUCCESS;
 }