From: Ben Pfaff Date: Sat, 23 Jan 2021 19:59:36 +0000 (-0800) Subject: zip-reader: Use endian conversion functions from integer-format.h. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a79d81c31cc3c74abccf7f71aab0e0b909df1a52;hp=8a490bdb254cf8d37eb4ac4edf91c7ef933c92dd;p=pspp zip-reader: Use endian conversion functions from integer-format.h. --- diff --git a/src/libpspp/zip-reader.c b/src/libpspp/zip-reader.c index 679bdc69eb..9f20999552 100644 --- a/src/libpspp/zip-reader.c +++ b/src/libpspp/zip-reader.c @@ -27,10 +27,9 @@ #include #include -#include - #include "str.h" +#include "integer-format.h" #include "zip-reader.h" #include "zip-private.h" @@ -149,39 +148,25 @@ get_bytes (FILE *f, void *x, size_t n) return (n == fread (x, 1, n, f)); } -static bool get_u32 (FILE *f, uint32_t *v) WARN_UNUSED_RESULT; - - /* Read a 32 bit value from F */ -static bool +static bool WARN_UNUSED_RESULT get_u32 (FILE *f, uint32_t *v) { uint32_t x; if (!get_bytes (f, &x, sizeof x)) return false; -#ifdef WORDS_BIGENDIAN - *v = bswap_32 (x); -#else - *v = x; -#endif + *v = le_to_native32 (x); return true; } -static bool get_u16 (FILE *f, uint16_t *v) WARN_UNUSED_RESULT; - - /* Read a 16 bit value from F */ -static bool +static bool WARN_UNUSED_RESULT get_u16 (FILE *f, uint16_t *v) { uint16_t x; if (!get_bytes (f, &x, sizeof x)) return false; -#ifdef WORDS_BIGENDIAN - *v = bswap_16 (x); -#else - *v = x; -#endif + *v = le_to_native16 (x); return true; }