Write debug_printf to avoid warnings and fix latency/cfd script

Signed-off-by: Rafael Ravedutti <rafaelravedutti@gmail.com>
This commit is contained in:
Rafael Ravedutti
2022-12-14 16:17:28 +01:00
parent 0e952964f7
commit 292138b270
3 changed files with 21 additions and 12 deletions

View File

@@ -19,11 +19,7 @@
# define ABS(a) ((a) >= 0 ? (a) : -(a))
#endif
#ifdef DEBUG
# define DEBUG_MESSAGE printf
#else
# define DEBUG_MESSAGE
#endif
#define DEBUG_MESSAGE debug_printf
#ifndef MAXLINE
# define MAXLINE 4096
@@ -45,5 +41,6 @@ extern int str2ff(const char *string);
extern const char* ff2str(int ff);
extern int get_num_threads();
extern void readline(char *line, FILE *fp);
extern void debug_printf(const char *format, ...);
#endif

View File

@@ -5,6 +5,7 @@
* license that can be found in the LICENSE file.
*/
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -91,3 +92,14 @@ void readline(char *line, FILE *fp) {
}
}
}
void debug_printf(const char *format, ...) {
#ifdef DEBUG
va_list arg;
int ret;
va_start(arg, format);
if((vfprintf(stdout, format, arg)) < 0) { perror("debug_printf()"); }
va_end(arg);
#endif
}