}
/* Quick and dirty: Read 2-byte and 4-byte integers from Zip file. */
-static int i2(const char *p) { return ((p[0] & 0xff) | ((p[1] & 0xff) << 8)); }
-static int i4(const char *p) { return (i2(p) | (i2(p + 2) << 16)); }
+static unsigned int
+i2(const void *p_)
+{
+ const unsigned char *p = p_;
+ return (p[0] | (p[1] << 8));
+}
+
+static unsigned int
+i4(const void *p_)
+{
+ const unsigned char *p = p_;
+ return (i2(p) | (i2(p + 2) << 16));
+}
static void verify_uncompressed_contents(const char *buff, size_t used)
{
static ssize_t memory_read(struct archive *, void *, const void **buff);
static ssize_t memory_write(struct archive *, void *, const void *, size_t);
-static int16_t le16(const void *_p) {
+static uint16_t le16(const void *_p) {
const uint8_t *p = _p;
- return (0xff & (int16_t)p[0]) | ((0xff & (int16_t)p[1]) << 8);
+ return p[0] | (p[1] << 8);
}
-static int32_t le32(const void *_p) {
+static uint32_t le32(const void *_p) {
const uint8_t *p = _p;
- int32_t v = 0xffff & (int32_t)le16(_p);
- return v + ((0xffff & (int32_t)le16(p + 2)) << 16);
+ return le16(p) | ((uint32_t)le16(p + 2) << 16);
}
-static int64_t le64(const void *_p) {
+static uint64_t le64(const void *_p) {
const uint8_t *p = _p;
- int64_t v = 0xffffffff & (int64_t)le32(_p);
- return v + ((0xffffffff & (int64_t)le32(p + 4)) << 32);
+ return le32(p) | ((uint64_t)le32(p + 4) << 32);
}
static ssize_t