Commit 70b9063c authored by Andy Polyakov's avatar Andy Polyakov
Browse files

e_os.h: omit PRIu64.



PRIu64 is error-prone with BIO_printf, so introduce and stick to custom
platform-neutral macro. 'll' allows to print 64-bit values on *all*
supported platforms, but it's problematic with -Wformat -Werror. Hence
use 'l' in identifiable LP64 cases.

Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3148)
parent 00eae742
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -548,8 +548,8 @@ int enc_main(int argc, char **argv)

    ret = 0;
    if (verbose) {
        BIO_printf(bio_err, "bytes read   :%8"PRIu64"\n", BIO_number_read(in));
        BIO_printf(bio_err, "bytes written:%8"PRIu64"\n", BIO_number_written(out));
        BIO_printf(bio_err, "bytes read   :%8"BIO_PRI64"u\n", BIO_number_read(in));
        BIO_printf(bio_err, "bytes written:%8"BIO_PRI64"u\n", BIO_number_written(out));
    }
 end:
    ERR_print_errors(bio_err);
+1 −1
Original line number Diff line number Diff line
@@ -1002,7 +1002,7 @@ static char *hexencode(const unsigned char *data, size_t len)
    int ilen = (int) outlen;

    if (outlen < len || ilen < 0 || outlen != (size_t)ilen) {
        BIO_printf(bio_err, "%s: %" PRIu64 "-byte buffer too large to hexencode\n",
        BIO_printf(bio_err, "%s: %"BIO_PRI64"u-byte buffer too large to hexencode\n",
                   opt_getprog(), (uint64_t)len);
        exit(1);
    }
+2 −2
Original line number Diff line number Diff line
@@ -2615,8 +2615,8 @@ static void print_stuff(BIO *bio, SSL *s, int full)
#endif

        BIO_printf(bio,
                   "---\nSSL handshake has read %" PRIu64
                   " bytes and written %" PRIu64 " bytes\n",
                   "---\nSSL handshake has read %"BIO_PRI64"u"
                   " bytes and written %"BIO_PRI64"u bytes\n",
                   BIO_number_read(SSL_get_rbio(s)),
                   BIO_number_written(SSL_get_wbio(s)));
    }
+2 −2
Original line number Diff line number Diff line
@@ -79,8 +79,8 @@ static int uint64_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,
                        int indent, const ASN1_PCTX *pctx)
{
    if ((it->size & INTxx_FLAG_SIGNED) == INTxx_FLAG_SIGNED)
        return BIO_printf(out, "%jd\n", *(int64_t *)pval);
    return BIO_printf(out, "%ju\n", *(uint64_t *)pval);
        return BIO_printf(out, "%"BIO_PRI64"d\n", *(int64_t *)pval);
    return BIO_printf(out, "%"BIO_PRI64"u\n", *(uint64_t *)pval);
}

/* 32-bit variants */
+6 −11
Original line number Diff line number Diff line
@@ -30,18 +30,13 @@ extern "C" {
# endif

/*
 * We need a format operator for some client tools for uint64_t.  If inttypes.h
 * isn't available or did not define it, just go with hard-coded.
 * BIO_printf format modifier for [u]int64_t.
 */
# if defined(OPENSSL_SYS_UEFI)
#  define PRIu64 "Lu"
# endif
# ifndef PRIu64
#  ifdef SIXTY_FOUR_BIT_LONG
#   define PRIu64 "lu"
# if defined(__LP64__) || (defined(__SIZEOF_LONG__) && __SIZEOF_LONG__==8)
#  define BIO_PRI64 "l"     /* 'll' does work "universally", but 'l' is
                             * here to shut -Wformat warnings in LP64... */
# else
#   define PRIu64 "llu"
#  endif
#  define BIO_PRI64 "ll"
# endif

# if !defined(NDEBUG) && !defined(OPENSSL_NO_STDIO)