diff options
author | 2019-10-09 14:10:22 +0200 | |
---|---|---|
committer | 2019-10-10 15:25:50 +0200 | |
commit | 172fa1a0994bc6f0986d17a8ee981ea931e8ff15 (patch) | |
tree | 2d27948d03f0ddf8814f299362856edb7b5d4bee /src | |
parent | 4c52ca4ea2c7b2d9f50fcc867d40e5b2170d4f3c (diff) |
Fix signed/unsigned types
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src')
-rw-r--r-- | src/cyn-server.c | 8 | ||||
-rw-r--r-- | src/expire.c | 2 | ||||
-rw-r--r-- | src/filedb.c | 2 | ||||
-rw-r--r-- | src/main-cynagorad.c | 14 | ||||
-rw-r--r-- | src/main-cynagoradm.c | 9 | ||||
-rw-r--r-- | src/socket.c | 6 |
6 files changed, 20 insertions, 21 deletions
diff --git a/src/cyn-server.c b/src/cyn-server.c index d751fda..78143a4 100644 --- a/src/cyn-server.c +++ b/src/cyn-server.c @@ -120,13 +120,13 @@ void dolog( client_t *cli, int c2s, - int count, + unsigned count, const char *fields[] ) { static const char types[3][6] = { "check", "agent", "admin" }; static const char dir[2] = { '>', '<' }; - int i; + unsigned i; fprintf(stderr, "%p%c%c%s", cli, dir[!c2s], dir[!c2s], types[cli->type]); for (i = 0 ; i < count ; i++) @@ -354,7 +354,7 @@ static void onrequest( client_t *cli, - int count, + unsigned count, const char *args[] ) { bool nextlog; @@ -565,7 +565,7 @@ on_client_event( goto terminate; nargs = prot_get(cli->prot, &args); while (nargs >= 0) { - onrequest(cli, nargs, args); + onrequest(cli, (unsigned)nargs, args); if (cli->invalid && !cli->relax) goto terminate; prot_next(cli->prot); diff --git a/src/expire.c b/src/expire.c index cfa5dff..23ce6ae 100644 --- a/src/expire.c +++ b/src/expire.c @@ -76,7 +76,7 @@ size_t exp2txt(time_t expire, char *buffer, size_t buflen) n = 0; #define ADD(C,U) \ if (expire >= U) { \ - n += snprintf(&b[n], sizeof b - n, "%lld" #C, (long long)(expire / U)); \ + n += snprintf(&b[n], sizeof b - (size_t)n, "%lld" #C, (long long)(expire / U)); \ expire %= U; \ } ADD(y,YEAR) diff --git a/src/filedb.c b/src/filedb.c index 86c302d..1fa5087 100644 --- a/src/filedb.c +++ b/src/filedb.c @@ -95,7 +95,7 @@ static const char uuid_names_v1[] = "b2c33494-995f-5cc2-9e5e-72ad412936a9\n--\n" static const char uuid_rules_v1[] = "73630c61-89a9-5e82-8b07-5e53eee785c8\n--\n"; /** length of the identifications */ -static const int uuidlen = 40; +static const uint32_t uuidlen = 40; struct filedb diff --git a/src/main-cynagorad.c b/src/main-cynagorad.c index 66b5ea7..db5408d 100644 --- a/src/main-cynagorad.c +++ b/src/main-cynagorad.c @@ -276,8 +276,8 @@ int main(int ac, char **av) fprintf(stderr, "can not find user '%s'\n", user); return -1; } - uid = pw->pw_uid; - gid = pw->pw_gid; + uid = (int)pw->pw_uid; + gid = (int)pw->pw_gid; } } if (group) { @@ -288,7 +288,7 @@ int main(int ac, char **av) fprintf(stderr, "can not find group '%s'\n", group); return -1; } - gid = gr->gr_gid; + gid = (int)gr->gr_gid; } } @@ -300,14 +300,14 @@ int main(int ac, char **av) /* drop privileges */ if (gid >= 0) { - rc = setgid(gid); + rc = setgid((gid_t)gid); if (rc < 0) { fprintf(stderr, "can not change group: %m\n"); return -1; } } if (uid >= 0) { - rc = setuid(uid); + rc = setuid((uid_t)uid); if (rc < 0) { fprintf(stderr, "can not change user: %m\n"); return -1; @@ -414,8 +414,8 @@ static void ensuredir(char *path, int length, int uid, int gid) exit(1); } /* set ownership */ - if ((uid != st.st_uid && uid >= 0) || (gid != st.st_gid && gid >= 0)) { - rc = chown(path, uid, gid); + if (((uid_t)uid != st.st_uid && uid >= 0) || ((gid_t)gid != st.st_gid && gid >= 0)) { + rc = chown(path, (uid_t)uid, (gid_t)gid); if (rc < 0) { fprintf(stderr, "can not own directory %s for uid=%d & gid=%d: %m\n", path, uid, gid); exit(1); diff --git a/src/main-cynagoradm.c b/src/main-cynagoradm.c index 7b657c0..b668abb 100644 --- a/src/main-cynagoradm.c +++ b/src/main-cynagoradm.c @@ -303,7 +303,7 @@ help_expiration_text[] = static cynagora_t *cynagora; static char buffer[4000]; -static int bufill; +static size_t bufill; static char *str[40]; static int nstr; static int pending; @@ -789,12 +789,11 @@ int main(int ac, char **av) for(;;) { rc = poll(fds, 2, -1); if (fds[0].revents & POLLIN) { - rc = (int)sizeof buffer - bufill; - rc = (int)read(0, buffer, rc); + rc = (int)read(0, buffer, sizeof buffer - bufill); if (rc == 0) break; if (rc > 0) { - bufill += rc; + bufill += (size_t)rc; while((p = memchr(buffer, '\n', bufill))) { /* process one line */ *p++ = 0; @@ -802,7 +801,7 @@ int main(int ac, char **av) while(str[nstr]) str[++nstr] = strtok(NULL, " \t"); do_all(nstr, str); - bufill -= (int)(p - buffer); + bufill -= (size_t)(p - buffer); if (!bufill) break; memmove(buffer, p, bufill); diff --git a/src/socket.c b/src/socket.c index bd6b804..fde9648 100644 --- a/src/socket.c +++ b/src/socket.c @@ -168,8 +168,8 @@ static int open_tcp(const char *spec, int server) errno = EINVAL; return -1; } - host = strndupa(spec, service++ - spec); - service = strndupa(service, tail - service); + host = strndupa(spec, (size_t)(service++ - spec)); + service = strndupa(service, (size_t)(tail - service)); /* get addr */ memset(&hint, 0, sizeof hint); @@ -256,7 +256,7 @@ static struct entry *get_entry(const char *uri, int *offset) } i--; l = (int)strlen(entries[i].prefix); - if (!strncmp(uri, entries[i].prefix, l)) + if (!strncmp(uri, entries[i].prefix, (size_t)l)) break; } |