Skip to content

Commit

Permalink
use appropriate integer types
Browse files Browse the repository at this point in the history
Mainly found with clang -Wconversion -Wshorten-64-to-32.
  • Loading branch information
leahneukirchen committed Oct 6, 2017
1 parent ce9ac3a commit 5f45b7d
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion mgenmid.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ int main()
rnd = ((uint64_t)lrand48() << 32) + lrand48();
}

rnd |= (1LL << 63); // set highest bit to force full width
rnd |= (1ULL << 63); // set highest bit to force full width

putchar('<');
printb36(((uint64_t)tp.tv_sec * 1000000LL + tp.tv_usec));
Expand Down
3 changes: 2 additions & 1 deletion mlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ struct linux_dirent64 {
void
listdir(char *dir)
{
int fd, nread;
int fd;
ssize_t nread;
char buf[BUF_SIZE];
struct linux_dirent64 *d;
int bpos;
Expand Down
7 changes: 4 additions & 3 deletions mmime.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ int gen_b64(uint8_t *s, off_t size)
return 0;
}

int gen_qp(uint8_t *s, off_t size, int maxlinelen, int linelen)
size_t
gen_qp(uint8_t *s, off_t size, size_t maxlinelen, size_t linelen)
{
off_t i;
int header = linelen > 0;
Expand Down Expand Up @@ -298,7 +299,7 @@ print_header(char *line) {

int prevq = 0; // was the previous word encoded as qp?

int linelen = s - line;
size_t linelen = s - line;

while (*s) {
size_t highbit = 0;
Expand Down Expand Up @@ -365,7 +366,7 @@ gen_build()
int intext = 0;

while (1) {
int read = getdelim(&line, &linelen, '\n', stdin);
ssize_t read = getdelim(&line, &linelen, '\n', stdin);
if (read == -1) {
if (feof(stdin))
break;
Expand Down
8 changes: 4 additions & 4 deletions mscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static time_t now;
static char default_fflag[] = "%c%u%r %-3n %10d %17f %t %2i%s";
static char *fflag = default_fflag;

int
ssize_t
u8putstr(FILE *out, char *s, ssize_t l, int pad)
{
ssize_t ol = l;
Expand Down Expand Up @@ -109,7 +109,7 @@ numline(char *file)
}

static char *
fmt_date(struct message *msg, int w, int iso)
fmt_date(struct message *msg, long w, int iso)
{
static char date[32];
char *v;
Expand Down Expand Up @@ -244,7 +244,7 @@ fmt_to_flag(struct message *msg)
}

static ssize_t
print_human(intmax_t i, int w)
print_human(intmax_t i, long w)
{
double d = i / 1024.0;
const char *u = "\0\0M\0G\0T\0P\0E\0Z\0Y\0";
Expand Down Expand Up @@ -310,7 +310,7 @@ oneline(char *file)
}
f++;

int w = 0;
long w = 0;
if ((*f >= '0' && *f <= '9') || *f == '-') {
errno = 0;
char *e;
Expand Down
6 changes: 3 additions & 3 deletions mshow.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ printable(int c)
return (unsigned)c-0x20 < 0x5f;
}

int
size_t
print_ascii(char *body, size_t bodylen)
{
if (safe_output) {
Expand Down Expand Up @@ -567,7 +567,7 @@ print_date_header(char *v)
printf(" (");
time_t d = t < now ? now - t : t - now;

int l;
char l;
if (d > 60*60*24*7*52) l = 'y';
else if (d > 60*60*24*7) l = 'w';
else if (d > 60*60*24) l = 'd';
Expand All @@ -576,7 +576,7 @@ print_date_header(char *v)
else l = 's';
int p = 3;

int z;
long z;
switch (l) {
case 'y':
z = d / (60*60*24*7*52);
Expand Down
4 changes: 2 additions & 2 deletions pipeto.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ pipeto(const char *cmdline)
errno = EINVAL;

// execvp failed, write errno to parent
long e = errno;
int e = errno;
if (write(pipe1[1], &e, sizeof e) < 0)
exit(111); // do a magic dance for gcc -Wunused-result
exit(111);
} else { // in parent
close(pipe1[1]);

long e;
int e;
ssize_t n = read(pipe1[0], &e, sizeof e);
if (n < 0)
e = errno;
Expand Down
2 changes: 1 addition & 1 deletion rfc2045.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ blaze822_multipart(struct message *msg, struct message **imsg)
if (!blaze822_mime_parameter(s, "boundary", &boundary, &boundaryend))
return 0;
char mboundary[256];
int boundarylen = boundaryend-boundary+2;
size_t boundarylen = boundaryend-boundary+2;

if (boundarylen >= 256)
return 0;
Expand Down
2 changes: 1 addition & 1 deletion rfc2047.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ blaze822_decode_rfc2047(char *dst, char *src, size_t dlen, char *tgtenc)
}

decchunk = dec;
int r = iconv(ic, &dec, &declen, &dst, &dlen);
ssize_t r = iconv(ic, &dec, &declen, &dst, &dlen);
if (r < 0) {
if (errno == E2BIG) {
break;
Expand Down
4 changes: 2 additions & 2 deletions rfc2231.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ blaze822_mime2231_parameter(char *s, char *name,
size_t dstlen = dst - dststart;
dst = dststart;

int r = iconv(ic, &dst, &dstlen, &tmpend, &tmplen);
if (r < 0) {
size_t r = iconv(ic, &dst, &dstlen, &tmpend, &tmplen);
if (r == (size_t)-1) {
free(tmp);
return 1;
}
Expand Down
6 changes: 3 additions & 3 deletions seq.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ blaze822_seq_cur(void)
if (!curlink)
curlink = blaze822_home_file("cur");

int r = readlink(curlink, b, sizeof b - 1);
ssize_t r = readlink(curlink, b, sizeof b - 1);
if (r < 0)
return 0;
b[r] = 0;
Expand Down Expand Up @@ -308,14 +308,14 @@ parse_parent(char *map, long *starto, long *stopo)
char *s, *t;
long line;

int previndent[256] = { 0 };
long previndent[256] = { 0 };

for (s = map, line = 0; s; s = t+1) {
t = strchr(s, '\n');
if (!t)
break;
line++;
int indent = 0;
long indent = 0;
while (*s && iswsp(*s)) {
s++;
indent++;
Expand Down

0 comments on commit 5f45b7d

Please sign in to comment.