all: use unsigned types for more variables that represent length
resolve build warnings on multiple platforms/toolchains
This commit is contained in:
parent
125c638c11
commit
0b6f95294e
5 changed files with 17 additions and 16 deletions
|
|
@ -161,7 +161,7 @@ capn_write_mem(struct capn *c, uint8_t *p, size_t sz, int packed)
|
||||||
{
|
{
|
||||||
struct capn_segment *seg;
|
struct capn_segment *seg;
|
||||||
struct capn_ptr root;
|
struct capn_ptr root;
|
||||||
int i;
|
unsigned i;
|
||||||
uint32_t headerlen;
|
uint32_t headerlen;
|
||||||
size_t datasz;
|
size_t datasz;
|
||||||
uint32_t *header;
|
uint32_t *header;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifndef min
|
#ifndef min
|
||||||
static int min(int a, int b) { return (a < b) ? a : b; }
|
static unsigned min(unsigned a, unsigned b) { return (a < b) ? a : b; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int capn_deflate(struct capn_stream* s) {
|
int capn_deflate(struct capn_stream* s) {
|
||||||
|
|
@ -12,7 +12,7 @@ int capn_deflate(struct capn_stream* s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
while (s->avail_in) {
|
while (s->avail_in) {
|
||||||
int i, sz = 0;
|
unsigned i, sz = 0;
|
||||||
uint8_t hdr = 0;
|
uint8_t hdr = 0;
|
||||||
uint8_t *p;
|
uint8_t *p;
|
||||||
|
|
||||||
|
|
@ -104,7 +104,7 @@ int capn_inflate(struct capn_stream* s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
while (s->avail_out) {
|
while (s->avail_out) {
|
||||||
int i, sz;
|
unsigned i, sz;
|
||||||
uint8_t hdr;
|
uint8_t hdr;
|
||||||
|
|
||||||
if (s->zeros > 0) {
|
if (s->zeros > 0) {
|
||||||
|
|
@ -143,7 +143,7 @@ int capn_inflate(struct capn_stream* s) {
|
||||||
return CAPN_NEED_MORE;
|
return CAPN_NEED_MORE;
|
||||||
|
|
||||||
memcpy(s->next_out, s->next_in+1, 8);
|
memcpy(s->next_out, s->next_in+1, 8);
|
||||||
s->raw = (int) s->next_in[9] * 8;
|
s->raw = s->next_in[9] * 8;
|
||||||
s->next_in += 10;
|
s->next_in += 10;
|
||||||
s->avail_in -= 10;
|
s->avail_in -= 10;
|
||||||
s->next_out += 8;
|
s->next_out += 8;
|
||||||
|
|
@ -154,7 +154,7 @@ int capn_inflate(struct capn_stream* s) {
|
||||||
/* 0x00 is followed by a single byte indicating
|
/* 0x00 is followed by a single byte indicating
|
||||||
* the count of consecutive zero value words
|
* the count of consecutive zero value words
|
||||||
* minus 1 */
|
* minus 1 */
|
||||||
s->zeros = (int) (s->next_in[1] + 1) * 8;
|
s->zeros = (s->next_in[1] + 1) * 8;
|
||||||
s->next_in += 2;
|
s->next_in += 2;
|
||||||
s->avail_in -= 2;
|
s->avail_in -= 2;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
static int g_AddTag = 1;
|
static int g_AddTag = 1;
|
||||||
#define ADD_TAG g_AddTag
|
#define ADD_TAG g_AddTag
|
||||||
|
|
@ -273,11 +274,11 @@ static void getSegments(struct capn *c, struct capn_segment **s, size_t num) {
|
||||||
ASSERT_EQ(num, c->segnum);
|
ASSERT_EQ(num, c->segnum);
|
||||||
|
|
||||||
s[0] = c->seglist;
|
s[0] = c->seglist;
|
||||||
for (int i = 1; i < num; i++) {
|
for (unsigned i = 1; i < num; i++) {
|
||||||
s[i] = s[i-1]->next;
|
s[i] = s[i-1]->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < num; i++) {
|
for (unsigned i = 0; i < num; i++) {
|
||||||
EXPECT_EQ(s[i]->id, i);
|
EXPECT_EQ(s[i]->id, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -314,7 +315,7 @@ TEST(WireFormat, StructRoundTrip_OneSegmentPerAllocation) {
|
||||||
|
|
||||||
struct capn ctx2;
|
struct capn ctx2;
|
||||||
memset(&ctx2, 0, sizeof(ctx2));
|
memset(&ctx2, 0, sizeof(ctx2));
|
||||||
for (int i = 0; i < sizeof(segments)/sizeof(segments[0]); i++) {
|
for (unsigned i = 0; i < sizeof(segments)/sizeof(segments[0]); i++) {
|
||||||
capn_append_segment(&ctx2, segments[i]);
|
capn_append_segment(&ctx2, segments[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -370,7 +371,7 @@ TEST(WireFormat, StructRoundTrip_OneSegmentPerAllocation_NoTag) {
|
||||||
|
|
||||||
struct capn ctx2;
|
struct capn ctx2;
|
||||||
memset(&ctx2, 0, sizeof(ctx2));
|
memset(&ctx2, 0, sizeof(ctx2));
|
||||||
for (int i = 0; i < sizeof(segments)/sizeof(segments[0]); i++) {
|
for (unsigned i = 0; i < sizeof(segments)/sizeof(segments[0]); i++) {
|
||||||
capn_append_segment(&ctx2, segments[i]);
|
capn_append_segment(&ctx2, segments[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -420,7 +421,7 @@ TEST(WireFormat, StructRoundTrip_MultipleSegmentsWithMultipleAllocations) {
|
||||||
|
|
||||||
struct capn ctx2;
|
struct capn ctx2;
|
||||||
memset(&ctx2, 0, sizeof(ctx2));
|
memset(&ctx2, 0, sizeof(ctx2));
|
||||||
for (int i = 0; i < sizeof(segments)/sizeof(segments[0]); i++) {
|
for (unsigned i = 0; i < sizeof(segments)/sizeof(segments[0]); i++) {
|
||||||
capn_append_segment(&ctx2, segments[i]);
|
capn_append_segment(&ctx2, segments[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
8
capn.h
8
capn.h
|
|
@ -94,7 +94,7 @@ struct capn_segment {
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
/* user settable */
|
/* user settable */
|
||||||
char *data;
|
char *data;
|
||||||
int len, cap;
|
unsigned len, cap;
|
||||||
void *user;
|
void *user;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -261,10 +261,10 @@ void capn_reset_copy(struct capn *c);
|
||||||
*/
|
*/
|
||||||
struct capn_stream {
|
struct capn_stream {
|
||||||
const uint8_t *next_in;
|
const uint8_t *next_in;
|
||||||
int avail_in;
|
unsigned avail_in;
|
||||||
uint8_t *next_out;
|
uint8_t *next_out;
|
||||||
int avail_out;
|
unsigned avail_out;
|
||||||
int zeros, raw;
|
unsigned zeros, raw;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CAPN_MISALIGNED -1
|
#define CAPN_MISALIGNED -1
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ TEST(Schema, ReadSimple) {
|
||||||
|
|
||||||
struct CodeGeneratorRequest req;
|
struct CodeGeneratorRequest req;
|
||||||
read_CodeGeneratorRequest(&req, root);
|
read_CodeGeneratorRequest(&req, root);
|
||||||
for (size_t i = 0; i < req.nodes.p.len; i++) {
|
for (int i = 0; i < req.nodes.p.len; i++) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue