Skip to content

Commit

Permalink
server BUGFIX proper print strings
Browse files Browse the repository at this point in the history
  • Loading branch information
michalvasko committed May 2, 2024
1 parent 6e30a50 commit 622a706
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ np2log_cb_nc2(const struct nc_session *session, NC_VERB_LEVEL level, const char
}

if (session && nc_session_get_id(session)) {
if (asprintf(&buf, "Session %u: %s", nc_session_get_id(session), msg) > -1) {
if (asprintf(&buf, "Session %" PRIu32 ": %s", nc_session_get_id(session), msg) > -1) {
msg = buf;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <grp.h>
#include <pwd.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -446,7 +447,7 @@ np2srv_content_id_cb(void *UNUSED(user_data))
uint32_t content_id;

content_id = sr_get_content_id(np2srv.sr_conn);
sprintf(buf, "%u", content_id);
sprintf(buf, "%" PRIu32, content_id);
return strdup(buf);
}

Expand Down
2 changes: 1 addition & 1 deletion src/netconf_confirmed_commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ ncc_rename_failed_file(const char *filename, const char *path)
{
char *new = NULL;

if (asprintf(&new, "%s/%s/%s-%ld.failed", np2srv.server_dir, NCC_DIR, filename, time(NULL)) == -1) {
if (asprintf(&new, "%s/%s/%s-%lld.failed", np2srv.server_dir, NCC_DIR, filename, (long long int)time(NULL)) == -1) {
EMEM;
return;
}
Expand Down
24 changes: 12 additions & 12 deletions src/netconf_monitoring.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ np2srv_ncm_oper_cb(sr_session_ctx_t *session, uint32_t UNUSED(sub_id), const cha
lyd_new_inner(root, NULL, "sessions", 0, &cont);

for (i = 0; i < stats.session_count; ++i) {
sprintf(buf, "%u", nc_session_get_id(stats.sessions[i]));
sprintf(buf, "%" PRIu32, nc_session_get_id(stats.sessions[i]));
lyd_new_list(cont, NULL, "session", 0, &list, buf);

switch (nc_session_get_ti(stats.sessions[i])) {
Expand All @@ -366,13 +366,13 @@ np2srv_ncm_oper_cb(sr_session_ctx_t *session, uint32_t UNUSED(sub_id), const cha
lyd_new_term(list, NULL, "login-time", time_str, 0, NULL);
free(time_str);

sprintf(buf, "%u", stats.session_stats[i].in_rpcs);
sprintf(buf, "%" PRIu32, stats.session_stats[i].in_rpcs);
lyd_new_term(list, NULL, "in-rpcs", buf, 0, NULL);
sprintf(buf, "%u", stats.session_stats[i].in_bad_rpcs);
sprintf(buf, "%" PRIu32, stats.session_stats[i].in_bad_rpcs);
lyd_new_term(list, NULL, "in-bad-rpcs", buf, 0, NULL);
sprintf(buf, "%u", stats.session_stats[i].out_rpc_errors);
sprintf(buf, "%" PRIu32, stats.session_stats[i].out_rpc_errors);
lyd_new_term(list, NULL, "out-rpc-errors", buf, 0, NULL);
sprintf(buf, "%u", stats.session_stats[i].out_notifications);
sprintf(buf, "%" PRIu32, stats.session_stats[i].out_notifications);
lyd_new_term(list, NULL, "out-notifications", buf, 0, NULL);
}
}
Expand All @@ -383,19 +383,19 @@ np2srv_ncm_oper_cb(sr_session_ctx_t *session, uint32_t UNUSED(sub_id), const cha
ly_time_time2str(stats.netconf_start_time, NULL, &time_str);
lyd_new_term(cont, NULL, "netconf-start-time", time_str, 0, NULL);
free(time_str);
sprintf(buf, "%u", stats.in_bad_hellos);
sprintf(buf, "%" PRIu32, stats.in_bad_hellos);
lyd_new_term(cont, NULL, "in-bad-hellos", buf, 0, NULL);
sprintf(buf, "%u", stats.in_sessions);
sprintf(buf, "%" PRIu32, stats.in_sessions);
lyd_new_term(cont, NULL, "in-sessions", buf, 0, NULL);
sprintf(buf, "%u", stats.dropped_sessions);
sprintf(buf, "%" PRIu32, stats.dropped_sessions);
lyd_new_term(cont, NULL, "dropped-sessions", buf, 0, NULL);
sprintf(buf, "%u", stats.global_stats.in_rpcs);
sprintf(buf, "%" PRIu32, stats.global_stats.in_rpcs);
lyd_new_term(cont, NULL, "in-rpcs", buf, 0, NULL);
sprintf(buf, "%u", stats.global_stats.in_bad_rpcs);
sprintf(buf, "%" PRIu32, stats.global_stats.in_bad_rpcs);
lyd_new_term(cont, NULL, "in-bad-rpcs", buf, 0, NULL);
sprintf(buf, "%u", stats.global_stats.out_rpc_errors);
sprintf(buf, "%" PRIu32, stats.global_stats.out_rpc_errors);
lyd_new_term(cont, NULL, "out-rpc-errors", buf, 0, NULL);
sprintf(buf, "%u", stats.global_stats.out_notifications);
sprintf(buf, "%" PRIu32, stats.global_stats.out_notifications);
lyd_new_term(cont, NULL, "out-notifications", buf, 0, NULL);

pthread_mutex_unlock(&stats.lock);
Expand Down
2 changes: 1 addition & 1 deletion src/netconf_subscribed_notifications.c
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,7 @@ np2srv_oper_sub_ntf_subscriptions_cb(sr_session_ctx_t *session, uint32_t UNUSED(
}

/* receivers */
if (asprintf(&path, "receivers/receiver[name='NETCONF session %u']", sub->nc_id) == -1) {
if (asprintf(&path, "receivers/receiver[name='NETCONF session %" PRIu32 "']", sub->nc_id) == -1) {
rc = sub_ntf_error_mem(session);
goto cleanup;
}
Expand Down

0 comments on commit 622a706

Please sign in to comment.