Skip to content

Commit

Permalink
Fix inconsistent sign in log__printf declaration.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed Mar 20, 2021
1 parent 9989a35 commit cca41d1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/logging_mosq.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#include <stdio.h>
#include <string.h>

#include "logging_mosq.h"
#include "mosquitto_internal.h"
#include "mosquitto.h"
#include "memory_mosq.h"

int log__printf(struct mosquitto *mosq, int priority, const char *fmt, ...)
int log__printf(struct mosquitto *mosq, unsigned int priority, const char *fmt, ...)
{
va_list va;
char *s;
Expand All @@ -50,7 +51,7 @@ int log__printf(struct mosquitto *mosq, int priority, const char *fmt, ...)
va_end(va);
s[len-1] = '\0'; /* Ensure string is null terminated. */

mosq->on_log(mosq, mosq->userdata, priority, s);
mosq->on_log(mosq, mosq->userdata, (int)priority, s);

mosquitto__free(s);
}
Expand Down
6 changes: 5 additions & 1 deletion lib/logging_mosq.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause

#include "mosquitto.h"

int log__printf(struct mosquitto *mosq, unsigned int priority, const char *fmt, ...);
#ifndef __GNUC__
#define __attribute__(attrib)
#endif

int log__printf(struct mosquitto *mosq, unsigned int level, const char *fmt, ...) __attribute__((format(printf, 3, 4)));

#endif
1 change: 1 addition & 0 deletions src/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#include <dlt/dlt.h>
#endif

#include "logging_mosq.h"
#include "mosquitto_broker_internal.h"
#include "memory_mosq.h"
#include "misc_mosq.h"
Expand Down
2 changes: 1 addition & 1 deletion src/mosquitto_broker_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#include "mosquitto_broker.h"
#include "mosquitto_plugin.h"
#include "mosquitto.h"
#include "logging_mosq.h"
#include "password_mosq.h"
#include "tls_mosq.h"
#include "uthash.h"
Expand Down Expand Up @@ -709,7 +710,6 @@ int control__unregister_callback(struct mosquitto__security_options *opts, MOSQ_
* ============================================================ */
int log__init(struct mosquitto__config *config);
int log__close(struct mosquitto__config *config);
int log__printf(struct mosquitto *mosq, unsigned int level, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
void log__internal(const char *fmt, ...) __attribute__((format(printf, 1, 2)));

/* ============================================================
Expand Down

0 comments on commit cca41d1

Please sign in to comment.