Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
mx_log: Fix format errors and type length
  • Loading branch information
mariux committed Nov 20, 2015
1 parent 2e0c15e commit 4aee7d5
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 23 deletions.
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -611,6 +611,7 @@ clean: CLEAN += test_mx_util
test: test_mx_util

test_mx_log.o: $(mx_log.h)
test_mx_log.o: CFLAGS += -Wno-format-zero-length
clean: CLEAN += test_mx_log.o

test_mx_log: mx_log.o
Expand Down
2 changes: 1 addition & 1 deletion mx_log.h
Expand Up @@ -53,7 +53,7 @@ int mx_log_level_get(void);
int mx_log_level_mxlog_to_syslog(int level);
int mx_log_level_syslog_to_mxlog(int level);

int mx_log_do(int level, char *file, unsigned long line, const char *func, const char *fmt, ...);
int mx_log_do(int level, char *file, unsigned long line, const char *func, const char *fmt, ...) __attribute__ ((format(printf, 5, 6)));;
int mx_log_printf(const char *fmt, ...);

int mx_log_finish(void);
Expand Down
10 changes: 5 additions & 5 deletions mx_mysql.c
Expand Up @@ -715,12 +715,12 @@ void _mx_mysql_bind_dump_index(struct mx_mysql_bind *b, unsigned int index)
{
mx_debug_value("%d", index);
mx_debug_value("%d", b->bind[index].buffer_type);
mx_debug_value("%d", b->bind[index].buffer_length);
mx_debug_value("%lu", b->bind[index].buffer_length);
mx_debug_value("%p", b->bind[index].buffer);
if (b->bind[index].buffer_type == MYSQL_TYPE_STRING)
mx_debug_value("%s", b->bind[index].buffer);
mx_debug_value("%s", (char *)b->bind[index].buffer);
mx_debug_value("%d", b->bind[index].is_unsigned);
mx_debug_value("%d", *b->bind[index].length);
mx_debug_value("%lu", *b->bind[index].length);
mx_debug_value("%d", *b->bind[index].is_null);
mx_debug_value("%d", *b->bind[index].error);
mx_debug_value("0x%x", b->data[index].flags);
Expand All @@ -738,7 +738,7 @@ void _mx_mysql_bind_dump(struct mx_mysql_bind *b)
}

mx_debug_value("%d", b->type);
mx_debug_value("%d", b->count);
mx_debug_value("%lu", b->count);

for (i=0; i < b->count; i++) {
_mx_mysql_bind_dump_index(b, i);
Expand Down Expand Up @@ -845,7 +845,7 @@ int mx_mysql_option_set_default_file(struct mx_mysql *mysql, char *fname)

if (fname && (*fname == '/') && (euidaccess(fname, R_OK) != 0)) {
mx_log_warning("MySQL ignoring defaults file: euidaccess(\"%s\", R_OK) failed: %m", fname);
mx_log_warning("MySQL falling back to mysql default config search path.", fname);
mx_log_warning("MySQL falling back to mysql default config search path.");
return -errno;
}

Expand Down
6 changes: 3 additions & 3 deletions mxqadmin.c
Expand Up @@ -163,7 +163,7 @@ int _close_group_for_user(struct mx_mysql *mysql, uint64_t group_id, uint64_t us
res = update_group_flags_closed(mysql, group_id, user_uid);

if (res == 0) {
mx_log_warning("no group with group_id=%lu found for user with uid=%d",
mx_log_warning("no group with group_id=%lu found for user with uid=%lu",
group_id, user_uid);
return -(errno=ENOENT);
}
Expand All @@ -186,7 +186,7 @@ int _reopen_group_for_user(struct mx_mysql *mysql, uint64_t group_id, uint64_t u
res = update_group_flags_reopen(mysql, group_id, user_uid);

if (res == 0) {
mx_log_warning("no group with group_id=%lu found for user with uid=%d",
mx_log_warning("no group with group_id=%lu found for user with uid=%lu",
group_id, user_uid);
return -(errno=ENOENT);
}
Expand Down Expand Up @@ -315,7 +315,7 @@ int main(int argc, char *argv[])
passwd = getpwuid(arg_uid);
if (!passwd) {
if (errno)
mx_log_err("Can't load user '%s': %m");
mx_log_err("Can't load user with uid '%lu': %m", arg_uid);
else
mx_log_err("Invalid argument for --user '%s': User not found.", optctl.optarg);
exit(EX_USAGE);
Expand Down
14 changes: 7 additions & 7 deletions mxqd.c
Expand Up @@ -1408,7 +1408,7 @@ void server_dump(struct mxq_server *server)
for (glist = ulist->groups; glist; glist = glist->next) {
group = &glist->group;

mx_log_info(" group=%s(%d):%lu %s jobs_max=%lu slots_per_job=%d jobs_in_q=%lu",
mx_log_info(" group=%s(%d):%lu %s jobs_max=%lu slots_per_job=%lu jobs_in_q=%lu",
group->user_name,
group->user_uid,
group->group_id,
Expand Down Expand Up @@ -1635,7 +1635,7 @@ int killall_over_memory(struct mxq_server *server)

pinfo = mx_proc_tree_proc_info(ptree, job->host_pid);
if (!pinfo) {
mx_log_warning("killall_over_memory(): Can't find process with pid %llu in process tree",
mx_log_warning("killall_over_memory(): Can't find process with pid %u in process tree",
job->host_pid);
continue;
}
Expand All @@ -1648,7 +1648,7 @@ int killall_over_memory(struct mxq_server *server)
if (jlist->max_sumrss/1024 <= group->job_memory)
continue;

mx_log_info("killall_over_memory(): used(%lluMiB) > requested(%lluMiB): Sending signal=%d to job=%s(%d):%lu:%lu pgrp=%d",
mx_log_info("killall_over_memory(): used(%lluMiB) > requested(%luMiB): Sending signal=%d to job=%s(%d):%lu:%lu pgrp=%d",
jlist->max_sumrss/1024,
group->job_memory,
signal,
Expand Down Expand Up @@ -1787,7 +1787,7 @@ static char *fspool_get_filename (struct mxq_server *server,long unsigned int jo
return fspool_filename;
}

static int fspool_process_file(struct mxq_server *server,char *filename,int job_id) {
static int fspool_process_file(struct mxq_server *server,char *filename, uint64_t job_id) {
FILE *in;
int res;

Expand Down Expand Up @@ -1836,7 +1836,7 @@ static int fspool_process_file(struct mxq_server *server,char *filename,int job_
return -errno;
}

mx_log_info("job finished (via fspool) : job %d pid %d status %d",job_id,pid,status);
mx_log_info("job finished (via fspool) : job %lu pid %d status %d", job_id, pid, status);

jlist = server_remove_job_list_by_pid(server, pid);
if (!jlist) {
Expand All @@ -1846,7 +1846,7 @@ static int fspool_process_file(struct mxq_server *server,char *filename,int job_

job = &jlist->job;
if (job->job_id != job_id) {
mx_log_warning("fspool_process_file: %s: job_id(pid)[%ld] != job_id(filename)[%ld]",
mx_log_warning("fspool_process_file: %s: job_id(pid)[%lu] != job_id(filename)[%lu]",
filename,
job->job_id,
job_id);
Expand Down Expand Up @@ -1969,7 +1969,7 @@ static int lost_scan_one(struct mxq_server *server)
return -errno;

if (!fspool_file_exists(server, job->job_id)) {
mx_log_warning("pid %u: process is gone. cancel job %d",
mx_log_warning("pid %u: process is gone. cancel job %lu",
jlist->job.host_pid,
jlist->job.job_id);
server_remove_job_list_by_pid(server, job->host_pid);
Expand Down
10 changes: 5 additions & 5 deletions mxqdump.c
Expand Up @@ -388,7 +388,7 @@ static int dump_jobs(struct mx_mysql *mysql, uint64_t group_id, uint64_t job_sta
grp_cnt = mxq_load_running_groups(mysql, &groups);
}

mx_debug_value("%lu", grp_cnt);
mx_debug_value("%d", grp_cnt);

for (g=0; g < grp_cnt; g++) {
grp = &groups[g];
Expand All @@ -398,7 +398,7 @@ static int dump_jobs(struct mx_mysql *mysql, uint64_t group_id, uint64_t job_sta
else
job_cnt = mxq_load_jobs_in_group(mysql, &jobs, grp);

mx_debug_value("%lu", job_cnt);
mx_debug_value("%d", job_cnt);

for (j=0; j < job_cnt; j++) {
job = &jobs[j];
Expand Down Expand Up @@ -783,10 +783,10 @@ int main(int argc, char *argv[])
mx_log_notice("No group found with group_id=%lu.", arg_group_id);
} else {
if (UINT64_HASVALUE(arg_uid) && !arg_all && !(arg_uid == ruid && !arg_running)) {
mx_log_debug("DO: print running groups for user with uid=%d", arg_uid);
mx_log_debug("DO: print running groups for user with uid=%lu", arg_uid);
cnt = dump_groups(mysql, MXQ_JOB_STATUS_RUNNING, arg_uid);
if (!cnt)
mx_log_notice("No running groups found for user with uid=%d", arg_uid);
mx_log_notice("No running groups found for user with uid=%lu", arg_uid);
} else if (arg_uid == UINT64_ALL && arg_all) {
mx_log_debug("DO: print all groups");
cnt = dump_groups(mysql, UINT64_ALL, UINT64_ALL);
Expand All @@ -796,7 +796,7 @@ int main(int argc, char *argv[])
mx_log_debug("DO: print all groups for user with uid=%lu", arg_uid);
cnt = dump_groups(mysql, UINT64_ALL, arg_uid);
if (!cnt)
mx_log_notice("No groups found for user with uid=%d.", arg_uid);
mx_log_notice("No groups found for user with uid=%lu.", arg_uid);
} else {
if (arg_uid == UINT64_ALL) {
mx_log_debug("DO: print all running groups");
Expand Down
2 changes: 1 addition & 1 deletion mxqkill.c
Expand Up @@ -332,7 +332,7 @@ int main(int argc, char *argv[])
passwd = getpwuid(arg_uid);
if (!passwd) {
if (errno)
mx_log_err("Can't load user '%s': %m");
mx_log_err("Can't load user with uid '%lu': %m", arg_uid);
else
mx_log_err("Invalid argument for --user '%s': User not found.", optctl.optarg);
exit(EX_USAGE);
Expand Down
2 changes: 1 addition & 1 deletion mxqsub.c
Expand Up @@ -909,7 +909,7 @@ int main(int argc, char *argv[])
if (!arg_program_name) {
p = strchr(argv[0], ' ');
if (p) {
mx_log_crit("<command> contains whitespace characters. Please set --command-alias if this is intended.", optctl.optarg);
mx_log_crit("<command> contains whitespace characters. Please set --command-alias if this is intended.");
exit(EX_CONFIG);
}
arg_program_name = argv[0];
Expand Down

0 comments on commit 4aee7d5

Please sign in to comment.