]> diplodocus.org Git - nmh/commitdiff
m_getfld.c: Use intmax_t and PRIdMAX to printf off_t values.
authorRalph Corderoy <ralph@inputplus.co.uk>
Wed, 9 Aug 2017 18:46:26 +0000 (19:46 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Wed, 9 Aug 2017 18:46:26 +0000 (19:46 +0100)
Compiling for ISO C90 prohibits casting to long long and printing with
"%lld", and printing as "%ld" is wrong on Mac OS where David reports
off_t is long long.

sbr/m_getfld.c

index 48551ae..84636a6 100644 (file)
@@ -8,6 +8,7 @@
 #include <h/mh.h>
 #include <h/mts.h>
 #include <h/utils.h>
 #include <h/mh.h>
 #include <h/mts.h>
 #include <h/utils.h>
+#include <inttypes.h>
 
 /*
    Purpose
 
 /*
    Purpose
@@ -446,8 +447,8 @@ enter_getfld (m_getfld_state_t *gstate, FILE *iob) {
                chunks of size MSG_INPUT_SIZE. */
             off = pos / MSG_INPUT_SIZE * MSG_INPUT_SIZE;
             if (fseeko(iob, off, SEEK_SET) == -1)
                chunks of size MSG_INPUT_SIZE. */
             off = pos / MSG_INPUT_SIZE * MSG_INPUT_SIZE;
             if (fseeko(iob, off, SEEK_SET) == -1)
-                adios("getfld's iob", "failed to set offset to skip: %ld",
-                    off);
+                adios("getfld's iob", "failed to set offset to skip: "
+                    "%" PRIdMAX, (intmax_t)off);
             num_read = fread (s->msg_buf, 1, MSG_INPUT_SIZE, iob);
             s->readpos = s->msg_buf  +  pos % MSG_INPUT_SIZE;
             s->end = s->msg_buf + num_read;
             num_read = fread (s->msg_buf, 1, MSG_INPUT_SIZE, iob);
             s->readpos = s->msg_buf  +  pos % MSG_INPUT_SIZE;
             s->end = s->msg_buf + num_read;
@@ -456,7 +457,8 @@ enter_getfld (m_getfld_state_t *gstate, FILE *iob) {
     }
 
     if (fseeko(iob, pos, SEEK_SET) == -1)
     }
 
     if (fseeko(iob, pos, SEEK_SET) == -1)
-        adios("getfld's iob", "failed to set offset on entry: %ld", pos);
+        adios("getfld's iob", "failed to set offset on entry: %" PRIdMAX,
+            (intmax_t)pos);
 }
 
 static void
 }
 
 static void
@@ -470,8 +472,8 @@ leave_getfld (m_getfld_state_t s) {
 
        /* Set file stream position so that callers can use ftell(). */
         if (fseeko(s->iob, s->total_bytes_read, SEEK_SET) == -1)
 
        /* Set file stream position so that callers can use ftell(). */
         if (fseeko(s->iob, s->total_bytes_read, SEEK_SET) == -1)
-            adios("getfld's iob", "failed to set offset: %ld",
-                s->total_bytes_read);
+            adios("getfld's iob", "failed to set offset: %" PRIdMAX,
+                (intmax_t)s->total_bytes_read);
 
         s->last_caller_pos = s->total_bytes_read;
     }
 
         s->last_caller_pos = s->total_bytes_read;
     }