kopia lustrzana https://github.com/Hamlib/Hamlib
Make SNPRINTF do something useful for Hamlib
Current SNPRINTF only triggers if there is a message too long in Hamlib AND there's a corresponding error in snprintf - not too likely. Make SNPRINTF diagnose any Hamlib errors, and eliminate a useless strlen(). FWIW, this shrinks libhamlib.so by about 45kB.pull/1608/head
rodzic
93d12b9c6a
commit
67c62e9b2a
|
@ -3766,7 +3766,7 @@ extern HAMLIB_EXPORT_VAR(char) debugmsgsave3[DEBUGMSGSAVE_SIZE]; // last-2 debu
|
|||
#define ELAPSED2 rig_debug(RIG_DEBUG_VERBOSE, "%s%d:%s: elapsed=%.0lfms\n", spaces(STATE(rig)->depth), STATE(rig)->depth, __func__, elapsed_ms(&__begin, HAMLIB_ELAPSED_GET));
|
||||
|
||||
// use this instead of snprintf for automatic detection of buffer limit
|
||||
#define SNPRINTF(s,n,...) { snprintf(s,n,##__VA_ARGS__);if (strlen(s) > n-1) fprintf(stderr,"****** %s(%d): buffer overflow ******\n", __func__, __LINE__); }
|
||||
#define SNPRINTF(s,n,...) { if (snprintf(s,n,##__VA_ARGS__) >= (n)) fprintf(stderr,"***** %s(%d): message truncated *****\n", __func__, __LINE__); }
|
||||
|
||||
extern HAMLIB_EXPORT(void)
|
||||
rig_debug HAMLIB_PARAMS((enum rig_debug_level_e debug_level,
|
||||
|
|
Ładowanie…
Reference in New Issue