Download raw body.
Pointer sign warnings
Stefan Sperling:
> But I would not mind seeing type cleanup work being done if naddy really
> wants to do it. Though it sounds like there are similar problems where
> the return for time invested would be higher.
I pretty quickly ran into some fundamental conflicts, like passing
the same buffer to str*() and SHA1*(), which take different signs.
That can't be solved without a cast somewhere.
There are, however, a bunch of low-hanging fruits:
(1) match the unsigned char type used by the zlib interface
(I used uint8_t. Should I use unsigned char instead?)
diff a1d20277a94295b6e07955a6fe63a2232562e4cf 2a0e76d42d84db849f8bf014205a78079a781ddb
blob - 02f9a9d5925c144aab1275b46ce59112abff7023
blob + df0038ffc2f2db7feca6d9cc6ba518f9df340906
--- lib/deflate.c
+++ lib/deflate.c
@@ -80,7 +80,7 @@ done:
}
static void
-csum_output(struct got_deflate_checksum *csum, const char *buf, size_t len)
+csum_output(struct got_deflate_checksum *csum, const uint8_t *buf, size_t len)
{
if (csum->output_crc)
*csum->output_crc = crc32(*csum->output_crc, buf, len);
blob - bb41647fe85bfae60cb467b43a93a531452887de
blob + 6eee636c9f50d9e8a6efef4d4aad6daf6373cdf1
--- lib/got_lib_deflate.h
+++ lib/got_lib_deflate.h
@@ -24,9 +24,9 @@ struct got_deflate_checksum {
struct got_deflate_buf {
z_stream z;
- char *inbuf;
+ uint8_t *inbuf;
size_t inlen;
- char *outbuf;
+ uint8_t *outbuf;
size_t outlen;
int flags;
#define GOT_DEFLATE_F_HAVE_MORE 0x01
blob - 3833fedc8b779ac09969970c0ae89d5732c651cf
blob + 4ddc5aac63e46a5562147f8b561c4dea76cad65c
--- lib/got_lib_inflate.h
+++ lib/got_lib_inflate.h
@@ -30,9 +30,9 @@ struct got_inflate_checksum {
struct got_inflate_buf {
z_stream z;
- char *inbuf;
+ uint8_t *inbuf;
size_t inlen;
- char *outbuf;
+ uint8_t *outbuf;
size_t outlen;
int flags;
#define GOT_INFLATE_F_HAVE_MORE 0x01
blob - e68e173747b3f8c673775b8a2b0926048e870407
blob + 68d7827eb3d5b571371f7aefe1e7153217177869
--- lib/inflate.c
+++ lib/inflate.c
@@ -84,7 +84,7 @@ done:
}
static void
-csum_input(struct got_inflate_checksum *csum, const char *buf, size_t len)
+csum_input(struct got_inflate_checksum *csum, const uint8_t *buf, size_t len)
{
if (csum->input_crc)
*csum->input_crc = crc32(*csum->input_crc, buf, len);
@@ -94,7 +94,7 @@ csum_input(struct got_inflate_checksum *csum, const ch
}
static void
-csum_output(struct got_inflate_checksum *csum, const char *buf, size_t len)
+csum_output(struct got_inflate_checksum *csum, const uint8_t *buf, size_t len)
{
if (csum->output_crc)
*csum->output_crc = crc32(*csum->output_crc, buf, len);
@@ -119,7 +119,7 @@ got_inflate_read(struct got_inflate_buf *zb, FILE *f,
if (consumed)
*consumed = 0;
do {
- char *csum_in = NULL, *csum_out = NULL;
+ uint8_t *csum_in = NULL, *csum_out = NULL;
size_t csum_avail_in = 0, csum_avail_out = 0;
if (z->avail_in == 0) {
@@ -179,7 +179,7 @@ got_inflate_read_fd(struct got_inflate_buf *zb, int fd
if (consumed)
*consumed = 0;
do {
- char *csum_in = NULL, *csum_out = NULL;
+ uint8_t *csum_in = NULL, *csum_out = NULL;
size_t csum_avail_in = 0, csum_avail_out = 0;
if (z->avail_in == 0) {
@@ -238,7 +238,7 @@ got_inflate_read_mmap(struct got_inflate_buf *zb, uint
*consumed = 0;
do {
- char *csum_in = NULL, *csum_out = NULL;
+ uint8_t *csum_in = NULL, *csum_out = NULL;
size_t csum_avail_in = 0, csum_avail_out = 0;
size_t last_total_in = zb->z.total_in;
blob - 4c0fd4f7fc733881e493f8944da591fe3502b689
blob + dfcc9099ca77bca83c34abf28dcf2e82742f59be
--- lib/object_parse.c
+++ lib/object_parse.c
@@ -210,7 +210,7 @@ got_object_read_header(struct got_object **obj, int fd
{
const struct got_error *err;
struct got_inflate_buf zb;
- char *buf;
+ uint8_t *buf;
const size_t zbsize = 64;
size_t outlen, totlen;
int nbuf = 1;
@@ -234,7 +234,7 @@ got_object_read_header(struct got_object **obj, int fd
break;
totlen += outlen;
if (memchr(zb.outbuf, '\0', outlen) == NULL) {
- char *newbuf;
+ uint8_t *newbuf;
nbuf++;
newbuf = recallocarray(buf, nbuf - 1, nbuf, zbsize);
if (newbuf == NULL) {
--
Christian "naddy" Weisgerber naddy@mips.inka.de
Pointer sign warnings