add_compile_options(-Wall -Wextra -Wconversion)
add_compile_options(-Wno-unused-parameter) # frankly not using a parameter does it care?
-add_compile_options(-Wno-sign-compare -Wno-sign-conversion)
add_compile_options(-Werror=maybe-uninitialized)
add_compile_options(-Werror=implicit-function-declaration)
add_compile_options(-ffunction-sections -fdata-sections)
struct cynara_configuration *conf;
struct cynara *client;
char buffer[4000];
-int bufill;
+size_t bufill;
char *str[40];
int nstr;
int pollfd;
void adm_set()
{
struct cynara_admin_policy **policies, *p;
- int n, i;
+ unsigned n, i;
- n = (nstr - 2) / 4;
- policies = malloc((1 + n) * sizeof *policies + n * sizeof **policies);
+ n = (unsigned)((nstr - 2) / 4);
+ policies = malloc((1 + n) * (sizeof *policies) + n * sizeof **policies);
policies[n] = NULL;
p = (struct cynara_admin_policy*)(&policies[n + 1]);
for (i = 0 ; i < n ; i++, p++) {
if (ev.data.fd == 0) {
if (ev.events & EPOLLIN) {
- 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;
if (action())
goto terminate;
/* next line if any */
- bufill -= (int)(p - buffer);
+ bufill -= (size_t)(p - buffer);
if (!bufill)
break;
memmove(buffer, p, bufill);
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++)
void
onrequest(
client_t *cli,
- int count,
+ unsigned count,
const char *args[]
) {
bool nextlog;
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);
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)
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
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) {
fprintf(stderr, "can not find group '%s'\n", group);
return -1;
}
- gid = gr->gr_gid;
+ gid = (int)gr->gr_gid;
}
}
/* 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;
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);
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;
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;
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);
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);
}
i--;
l = (int)strlen(entries[i].prefix);
- if (!strncmp(uri, entries[i].prefix, l))
+ if (!strncmp(uri, entries[i].prefix, (size_t)l))
break;
}