From: Ralph Corderoy Date: Wed, 9 Aug 2017 18:46:26 +0000 (+0100) Subject: m_getfld.c: Use intmax_t and PRIdMAX to printf off_t values. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/9c7b5289d70448fb5b118abbea5a4d37afdf00be?hp=df646add9dde90130753c06938e425c8f8f39c0f m_getfld.c: Use intmax_t and PRIdMAX to printf off_t values. 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. --- diff --git a/sbr/m_getfld.c b/sbr/m_getfld.c index 48551ae5..84636a6f 100644 --- a/sbr/m_getfld.c +++ b/sbr/m_getfld.c @@ -8,6 +8,7 @@ #include #include #include +#include /* 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) - 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; @@ -456,7 +457,8 @@ enter_getfld (m_getfld_state_t *gstate, FILE *iob) { } 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 @@ -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) - 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; }