Commit c5224a9c authored by hpi1's avatar hpi1

Mark debug() and str_printf() printf-like functions so that compiler can check...

Mark debug() and str_printf() printf-like functions so that compiler can check argument types against format string
Mark str_printf() malloc -like function

parent c6cb63bf
#ifndef LIBBLURAY_ATTRIBUTES_H_
#define LIBBLURAY_ATTRIBUTES_H_
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3 )
# define BD_ATTR_FORMAT_PRINTF(format,var) __attribute__((__format__(__printf__,format,var)))
# define BD_ATTR_MALLOC __attribute__((__malloc__))
#else
# define BD_ATTR_FORMAT_PRINTF(format,var)
# define BD_ATTR_MALLOC
#endif
#endif /* LIBBLURAY_ATTRIBUTES_H_ */
......@@ -21,7 +21,7 @@ char *print_hex(uint8_t *buf, int count)
return out;
}
void debug(char *file, int line, uint32_t mask, const char *format, ...)
void debug(const char *file, int line, uint32_t mask, const char *format, ...)
{
// Only call getenv() once.
if (!debug_init) {
......
......@@ -7,6 +7,8 @@
#include <stdint.h>
#include <string.h>
#include "attributes.h"
#define DEBUG(X,Y,...) debug(__FILE__,__LINE__,X,Y,##__VA_ARGS__)
enum debug_mask_enum {
......@@ -28,6 +30,6 @@ typedef enum debug_mask_enum debug_mask_t;
extern debug_mask_t debug_mask;
char *print_hex(uint8_t *str, int count);
void debug(char *file, int line, uint32_t mask, const char *format, ...);
void debug(const char *file, int line, uint32_t mask, const char *format, ...) BD_ATTR_FORMAT_PRINTF(4,5);
#endif /* LOGGING_H_ */
......@@ -2,6 +2,8 @@
#ifndef STRUTL_H_
#define STRUTL_H_
char * str_printf(const char *fmt, ...);
#include "attributes.h"
char * str_printf(const char *fmt, ...) BD_ATTR_FORMAT_PRINTF(1,2) BD_ATTR_MALLOC;
#endif // STRUTL_H_
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment