vsh: Replace vshPrint macro with function

The macro would eat the first parameter. In some cases the format string
for vshPrint was eaten. In other cases the calls referenced variables
which did not exist in the given context. Avoid errors by doing compile
time checking.
This commit is contained in:
Peter Krempa
2016-02-12 14:09:02 +01:00
parent 018010f05c
commit 27fa42b24c
3 changed files with 26 additions and 10 deletions

View File

@@ -300,6 +300,8 @@ const vshCmdOpt *vshCommandOptArgv(vshControl *ctl, const vshCmd *cmd,
bool vshCommandArgvParse(vshControl *ctl, int nargs, char **argv);
int vshCommandOptTimeoutToMs(vshControl *ctl, const vshCmd *cmd, int *timeout);
void vshPrint(vshControl *ctl, const char *format, ...)
ATTRIBUTE_FMT_PRINTF(2, 3);
void vshPrintExtra(vshControl *ctl, const char *format, ...)
ATTRIBUTE_FMT_PRINTF(2, 3);
bool vshInit(vshControl *ctl, const vshCmdGrp *groups, const vshCmdDef *set);
@@ -308,9 +310,6 @@ void vshDeinit(vshControl *ctl);
void vshDebug(vshControl *ctl, int level, const char *format, ...)
ATTRIBUTE_FMT_PRINTF(3, 4);
/* XXX: add batch support */
# define vshPrint(_ctl, ...) vshPrintExtra(NULL, __VA_ARGS__)
/* User visible sort, so we want locale-specific case comparison. */
# define vshStrcasecmp(S1, S2) strcasecmp(S1, S2)
int vshNameSorter(const void *a, const void *b);