added printf format check for hex logs

master
Joseph Giovatto 7 years ago committed by Andre Puschmann
parent 2dcd6695bc
commit 4e05266ea8

@ -129,10 +129,14 @@ public:
virtual void debug(const char * message, ...) __attribute__ ((format (printf, 2, 3))) = 0; virtual void debug(const char * message, ...) __attribute__ ((format (printf, 2, 3))) = 0;
// Same with hex dump // Same with hex dump
virtual void error_hex(uint8_t *hex, int size, std::string message, ...){error("error_hex not implemented.\n");} virtual void error_hex(uint8_t *hex, int size, const char *, ...) __attribute__((format (printf, 4, 5)))
virtual void warning_hex(uint8_t *hex, int size, std::string message, ...){error("warning_hex not implemented.\n");} {error("error_hex not implemented.\n");}
virtual void info_hex(uint8_t *hex, int size, std::string message, ...){error("info_hex not implemented.\n");} virtual void warning_hex(uint8_t *hex, int size, const char *, ...) __attribute__((format (printf, 4, 5)))
virtual void debug_hex(uint8_t *hex, int size, std::string message, ...){error("debug_hex not implemented.\n");} {error("warning_hex not implemented.\n");}
virtual void info_hex(uint8_t *hex, int size, const char *, ...) __attribute__((format (printf, 4, 5)))
{error("info_hex not implemented.\n");}
virtual void debug_hex(uint8_t *hex, int size, const char *, ...) __attribute__((format (printf, 4, 5)))
{error("debug_hex not implemented.\n");}
protected: protected:
std::string get_service_name() { return service_name; } std::string get_service_name() { return service_name; }

@ -63,10 +63,10 @@ public:
void info(const char * message, ...); void info(const char * message, ...);
void debug(const char * message, ...); void debug(const char * message, ...);
void error_hex(uint8_t *hex, int size, std::string message, ...); void error_hex(uint8_t *hex, int size, const char * message, ...);
void warning_hex(uint8_t *hex, int size, std::string message, ...); void warning_hex(uint8_t *hex, int size, const char * message, ...);
void info_hex(uint8_t *hex, int size, std::string message, ...); void info_hex(uint8_t *hex, int size, const char * message, ...);
void debug_hex(uint8_t *hex, int size, std::string message, ...); void debug_hex(uint8_t *hex, int size, const char * message, ...);
class time_itf { class time_itf {
public: public:

@ -190,45 +190,45 @@ void log_filter::debug(const char * message, ...) {
} }
} }
void log_filter::error_hex(uint8_t *hex, int size, std::string message, ...) { void log_filter::error_hex(uint8_t *hex, int size, const char * message, ...) {
if (level >= LOG_LEVEL_ERROR) { if (level >= LOG_LEVEL_ERROR) {
char *args_msg; char *args_msg;
va_list args; va_list args;
va_start(args, message); va_start(args, message);
if(vasprintf(&args_msg, message.c_str(), args) > 0) if(vasprintf(&args_msg, message, args) > 0)
all_log(LOG_LEVEL_ERROR, tti, args_msg, hex, size); all_log(LOG_LEVEL_ERROR, tti, args_msg, hex, size);
va_end(args); va_end(args);
free(args_msg); free(args_msg);
} }
} }
void log_filter::warning_hex(uint8_t *hex, int size, std::string message, ...) { void log_filter::warning_hex(uint8_t *hex, int size, const char * message, ...) {
if (level >= LOG_LEVEL_WARNING) { if (level >= LOG_LEVEL_WARNING) {
char *args_msg; char *args_msg;
va_list args; va_list args;
va_start(args, message); va_start(args, message);
if(vasprintf(&args_msg, message.c_str(), args) > 0) if(vasprintf(&args_msg, message, args) > 0)
all_log(LOG_LEVEL_WARNING, tti, args_msg, hex, size); all_log(LOG_LEVEL_WARNING, tti, args_msg, hex, size);
va_end(args); va_end(args);
free(args_msg); free(args_msg);
} }
} }
void log_filter::info_hex(uint8_t *hex, int size, std::string message, ...) { void log_filter::info_hex(uint8_t *hex, int size, const char * message, ...) {
if (level >= LOG_LEVEL_INFO) { if (level >= LOG_LEVEL_INFO) {
char *args_msg; char *args_msg;
va_list args; va_list args;
va_start(args, message); va_start(args, message);
if(vasprintf(&args_msg, message.c_str(), args) > 0) if(vasprintf(&args_msg, message, args) > 0)
all_log(LOG_LEVEL_INFO, tti, args_msg, hex, size); all_log(LOG_LEVEL_INFO, tti, args_msg, hex, size);
va_end(args); va_end(args);
free(args_msg); free(args_msg);
} }
} }
void log_filter::debug_hex(uint8_t *hex, int size, std::string message, ...) { void log_filter::debug_hex(uint8_t *hex, int size, const char * message, ...) {
if (level >= LOG_LEVEL_DEBUG) { if (level >= LOG_LEVEL_DEBUG) {
char *args_msg; char *args_msg;
va_list args; va_list args;
va_start(args, message); va_start(args, message);
if(vasprintf(&args_msg, message.c_str(), args) > 0) if(vasprintf(&args_msg, message, args) > 0)
all_log(LOG_LEVEL_DEBUG, tti, args_msg, hex, size); all_log(LOG_LEVEL_DEBUG, tti, args_msg, hex, size);
va_end(args); va_end(args);
free(args_msg); free(args_msg);

@ -602,8 +602,8 @@ int phch_worker::decode_pusch(srslte_enb_ul_pusch_t *grants, uint32_t nof_pusch)
} }
*/ */
log_h->info_hex(grants[i].data, phy_grant.mcs.tbs / 8, log_h->info_hex(grants[i].data, phy_grant.mcs.tbs / 8,
"PUSCH: rnti=0x%x, prb=(%d,%d), tbs=%d, mcs=%d, rv=%d, snr=%.1f dB, n_iter=%d, crc=%s%s%s%s%s%s%s\n", "PUSCH: rnti=0x%x, prb=(%d,%d), tbs=%d, mcs=%d, idx=%d, rv=%d, snr=%.1f dB, n_iter=%d, crc=%s%s%s%s%s%s%s%s\n",
rnti, phy_grant.n_prb[0], phy_grant.n_prb[0] + phy_grant.L_prb, rnti, phy_grant.n_prb[0], phy_grant.n_prb[0], phy_grant.L_prb,
phy_grant.mcs.tbs / 8, phy_grant.mcs.idx, grants[i].grant.rv_idx, phy_grant.mcs.tbs / 8, phy_grant.mcs.idx, grants[i].grant.rv_idx,
snr_db, snr_db,
srslte_pusch_last_noi(&enb_ul.pusch), srslte_pusch_last_noi(&enb_ul.pusch),

Loading…
Cancel
Save