Fix -Wformat errors

Fixes two types of errors which appear when building with gcc-5.0.0

- format ‘%d’ expects argument of type ‘int’, but argument X has type ‘unsigned int’
- format ‘%a’ expects argument of type ‘float *’, but argument X has type ‘char **’

Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
This commit is contained in:
Petr Lautrbach 2015-03-13 15:54:09 +01:00 committed by Stephen Smalley
parent 93e557cab6
commit 417cb8d076
12 changed files with 27 additions and 27 deletions

View File

@ -288,7 +288,7 @@ void avc_av_stats(void)
avc_release_lock(avc_lock);
avc_log(SELINUX_INFO, "%s: %d AV entries and %d/%d buckets used, "
avc_log(SELINUX_INFO, "%s: %u AV entries and %d/%d buckets used, "
"longest chain length %d\n", avc_prefix,
avc_cache.active_nodes,
slots_used, AVC_CACHE_SLOTS, max_chain_len);
@ -471,7 +471,7 @@ static int avc_insert(security_id_t ssid, security_id_t tsid,
if (ae->avd.seqno < avc_cache.latest_notif) {
avc_log(SELINUX_WARNING,
"%s: seqno %d < latest_notif %d\n", avc_prefix,
"%s: seqno %u < latest_notif %u\n", avc_prefix,
ae->avd.seqno, avc_cache.latest_notif);
errno = EAGAIN;
rc = -1;

View File

@ -125,14 +125,14 @@ static int avc_netlink_receive(char *buf, unsigned buflen, int blocking)
if (nladdrlen != sizeof nladdr) {
avc_log(SELINUX_WARNING,
"%s: warning: netlink address truncated, len %d?\n",
"%s: warning: netlink address truncated, len %u?\n",
avc_prefix, nladdrlen);
return -1;
}
if (nladdr.nl_pid) {
avc_log(SELINUX_WARNING,
"%s: warning: received spoofed netlink packet from: %d\n",
"%s: warning: received spoofed netlink packet from: %u\n",
avc_prefix, nladdr.nl_pid);
return -1;
}
@ -197,7 +197,7 @@ static int avc_netlink_process(char *buf)
case SELNL_MSG_POLICYLOAD:{
struct selnl_msg_policyload *msg = NLMSG_DATA(nlh);
avc_log(SELINUX_INFO,
"%s: received policyload notice (seqno=%d)\n",
"%s: received policyload notice (seqno=%u)\n",
avc_prefix, msg->seqno);
rc = avc_ss_reset(msg->seqno);
if (rc < 0) {

View File

@ -124,7 +124,7 @@ void sidtab_sid_stats(struct sidtab *h, char *buf, int buflen)
}
snprintf(buf, buflen,
"%s: %d SID entries and %d/%d buckets used, longest "
"%s: %u SID entries and %d/%d buckets used, longest "
"chain length %d\n", avc_prefix, h->nel, slots_used,
SIDTAB_SIZE, max_chain_len);
}

View File

@ -101,7 +101,7 @@ static int process_line(struct selabel_handle *rec,
items = sscanf(line_buf, "%255s %255s", prop, context);
if (items != 2) {
selinux_log(SELINUX_WARNING,
"%s: line %d is missing fields, skipping\n", path,
"%s: line %u is missing fields, skipping\n", path,
lineno);
return 0;
}
@ -111,7 +111,7 @@ static int process_line(struct selabel_handle *rec,
spec_arr[nspec].property_key = strdup(prop);
if (!spec_arr[nspec].property_key) {
selinux_log(SELINUX_WARNING,
"%s: out of memory at line %d on prop %s\n",
"%s: out of memory at line %u on prop %s\n",
path, lineno, prop);
return -1;
@ -120,7 +120,7 @@ static int process_line(struct selabel_handle *rec,
spec_arr[nspec].lr.ctx_raw = strdup(context);
if (!spec_arr[nspec].lr.ctx_raw) {
selinux_log(SELINUX_WARNING,
"%s: out of memory at line %d on context %s\n",
"%s: out of memory at line %u on context %s\n",
path, lineno, context);
return -1;
}
@ -128,7 +128,7 @@ static int process_line(struct selabel_handle *rec,
if (rec->validating) {
if (selabel_validate(rec, &spec_arr[nspec].lr) < 0) {
selinux_log(SELINUX_WARNING,
"%s: line %d has invalid context %s\n",
"%s: line %u has invalid context %s\n",
path, lineno, spec_arr[nspec].lr.ctx_raw);
}
}

View File

@ -105,12 +105,12 @@ process_line(const char *path, char *line_buf, unsigned int line_num,
* <object class> <object name> <security context>
*/
type = key = context = temp = NULL;
items = sscanf(line_buf, "%as %as %as %as",
items = sscanf(line_buf, "%ms %ms %ms %ms",
&type, &key, &context, &temp);
if (items != 3) {
if (items > 0)
selinux_log(SELINUX_WARNING,
"%s: line %d has invalid format, skipped",
"%s: line %u has invalid format, skipped",
path, line_num);
goto skip;
}
@ -146,7 +146,7 @@ process_line(const char *path, char *line_buf, unsigned int line_num,
spec->type = SELABEL_DB_DATATYPE;
else {
selinux_log(SELINUX_WARNING,
"%s: line %d has invalid object type %s\n",
"%s: line %u has invalid object type %s\n",
path, line_num, type);
goto skip;
}

View File

@ -170,10 +170,10 @@ static int process_line(struct selabel_handle *rec,
/* Skip comment lines and empty lines. */
if (*buf_p == '#' || *buf_p == 0)
return 0;
items = sscanf(line_buf, "%as %as %as", &regex, &type, &context);
items = sscanf(line_buf, "%ms %ms %ms", &regex, &type, &context);
if (items < 2) {
COMPAT_LOG(SELINUX_WARNING,
"%s: line %d is missing fields, skipping\n", path,
"%s: line %u is missing fields, skipping\n", path,
lineno);
if (items == 1)
free(regex);
@ -204,7 +204,7 @@ static int process_line(struct selabel_handle *rec,
spec_arr[nspec].stem_id = find_stem_from_spec(data, regex);
spec_arr[nspec].regex_str = regex;
if (rec->validating && compile_regex(data, &spec_arr[nspec], &errbuf)) {
COMPAT_LOG(SELINUX_WARNING, "%s: line %d has invalid regex %s: %s\n",
COMPAT_LOG(SELINUX_WARNING, "%s: line %u has invalid regex %s: %s\n",
path, lineno, regex, (errbuf ? errbuf : "out of memory"));
}
@ -214,7 +214,7 @@ static int process_line(struct selabel_handle *rec,
if (type) {
mode_t mode = string_to_mode(type);
if (mode == (mode_t)-1) {
COMPAT_LOG(SELINUX_WARNING, "%s: line %d has invalid file type %s\n",
COMPAT_LOG(SELINUX_WARNING, "%s: line %u has invalid file type %s\n",
path, lineno, type);
mode = 0;
}

View File

@ -44,10 +44,10 @@ static int process_line(const char *path, char *line_buf, int pass,
/* Skip comment lines and empty lines. */
if (*buf_p == '#' || *buf_p == 0)
return 0;
items = sscanf(line_buf, "%as %as ", &key, &context);
items = sscanf(line_buf, "%ms %ms ", &key, &context);
if (items < 2) {
selinux_log(SELINUX_WARNING,
"%s: line %d is missing fields, skipping\n", path,
"%s: line %u is missing fields, skipping\n", path,
lineno);
if (items == 1)
free(key);

View File

@ -46,10 +46,10 @@ static int process_line(const char *path, char *line_buf, int pass,
/* Skip comment lines and empty lines. */
if (*buf_p == '#' || *buf_p == 0)
return 0;
items = sscanf(line_buf, "%as %as %as ", &type, &key, &context);
items = sscanf(line_buf, "%ms %ms %ms ", &type, &key, &context);
if (items < 3) {
selinux_log(SELINUX_WARNING,
"%s: line %d is missing fields, skipping\n", path,
"%s: line %u is missing fields, skipping\n", path,
lineno);
if (items > 0)
free(type);
@ -76,7 +76,7 @@ static int process_line(const char *path, char *line_buf, int pass,
data->spec_arr[data->nspec].type = SELABEL_X_POLYSELN;
else {
selinux_log(SELINUX_WARNING,
"%s: line %d has invalid object type %s\n",
"%s: line %u has invalid object type %s\n",
path, lineno, type);
return 0;
}

View File

@ -541,7 +541,7 @@ int compat_validate(struct selabel_handle *rec,
if (rc < 0) {
if (lineno) {
COMPAT_LOG(SELINUX_WARNING,
"%s: line %d has invalid context %s\n",
"%s: line %u has invalid context %s\n",
path, lineno, *ctx);
} else {
COMPAT_LOG(SELINUX_WARNING,

View File

@ -73,7 +73,7 @@ static int process_file(struct saved_data *data, const char *filename)
spec->lr.ctx_raw = context;
spec->mode = string_to_mode(mode);
if (spec->mode == (mode_t)-1) {
fprintf(stderr, "%s: line %d has invalid file type %s\n",
fprintf(stderr, "%s: line %u has invalid file type %s\n",
regex, line_num + 1, mode);
spec->mode = 0;
}

View File

@ -86,7 +86,7 @@ int main(int argc, char **argv)
argv[i], pwd->pw_name);
else
syslog(LOG_NOTICE,
"The %s policy boolean was toggled by uid:%d",
"The %s policy boolean was toggled by uid:%u",
argv[i], getuid());
}

View File

@ -278,7 +278,7 @@ static int process_pam_config(FILE * cfg)
continue;
app = service = NULL;
ret = sscanf(buffer, "%as %as\n", &app, &service);
ret = sscanf(buffer, "%ms %ms\n", &app, &service);
if (ret < 2 || !app || !service)
goto err;
@ -1104,7 +1104,7 @@ int main(int argc, char *argv[])
* command when invoked by newrole.
*/
char *cmd = NULL;
rc = sscanf(argv[optind + 1], "%as", &cmd);
rc = sscanf(argv[optind + 1], "%ms", &cmd);
if (rc != EOF && cmd) {
char *app_service_name =
(char *)hashtab_search(app_service_names,