Skip to content

Commit 16152fa

Browse files
junjiemao1lijinxia
authored andcommitted
HV: debug: stop using ## __VA_ARGS__
It is an extension of GCC CPP to: * allow omitting a variable macro argument entirely, and * use ## __VA_ARGS__ to remove the the comma before ## __VA_ARGS__ when __VA_ARGS__ is empty. The only use of ## _VA_ARGS__ is to define the pr_xxx() macros, with the first argument being the format string and the rest the to-be-formatted arguments. The format string is explicitly spelled out because another macro pr_fmt() is used to add to the format string a prefix which is customizable by defining what pr_fmt() expands to. For C99 compliance, this patch changes the pr_xxx() macros in the following pattern. - #define pr_fatal(fmt, ...) \ - do_logmsg(LOG_FATAL, pr_fmt(fmt), ## __VA_ARGS__); \ + #define pr_fatal(...) \ + do_logmsg(LOG_FATAL, pr_prefix __VA_ARGS__); \ Reference: * https://gcc.gnu.org/onlinedocs/gcc/Variadic-Macros.html#Variadic-Macros Signed-off-by: Junjie Mao <junjie.mao@intel.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com>
1 parent 26b0899 commit 16152fa

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

hypervisor/arch/x86/guest/vioapic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* $FreeBSD$
2929
*/
3030

31-
#define pr_fmt(fmt) "vioapic: " fmt
31+
#define pr_prefix "vioapic: "
3232

3333
#include <hypervisor.h>
3434

hypervisor/arch/x86/guest/vlapic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* $FreeBSD$
2828
*/
2929

30-
#define pr_fmt(fmt) "vlapic: " fmt
30+
#define pr_prefix "vlapic: "
3131

3232
#include <hypervisor.h>
3333

hypervisor/arch/x86/guest/vpic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* SUCH DAMAGE.
2626
*/
2727

28-
#define pr_fmt(fmt) "vpic: " fmt
28+
#define pr_prefix "vpic: "
2929

3030
#include <hypervisor.h>
3131

hypervisor/arch/x86/vtd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030

31-
#define pr_fmt(fmt) "iommu: " fmt
31+
#define pr_prefix "iommu: "
3232

3333
#include <hypervisor.h>
3434

hypervisor/include/debug/logmsg.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -68,38 +68,38 @@ static inline void print_logmsg_buffer(__unused uint32_t cpu_id)
6868

6969
#endif /* HV_DEBUG */
7070

71-
#ifndef pr_fmt
72-
#define pr_fmt(fmt) fmt
71+
#ifndef pr_prefix
72+
#define pr_prefix
7373
#endif
7474

75-
#define pr_fatal(fmt, ...) \
76-
do { \
77-
do_logmsg(LOG_FATAL, pr_fmt(fmt), ##__VA_ARGS__); \
75+
#define pr_fatal(...) \
76+
do { \
77+
do_logmsg(LOG_FATAL, pr_prefix __VA_ARGS__); \
7878
} while (0)
7979

80-
#define pr_err(fmt, ...) \
81-
do { \
82-
do_logmsg(LOG_ERROR, pr_fmt(fmt), ##__VA_ARGS__); \
80+
#define pr_err(...) \
81+
do { \
82+
do_logmsg(LOG_ERROR, pr_prefix __VA_ARGS__); \
8383
} while (0)
8484

85-
#define pr_warn(fmt, ...) \
86-
do { \
87-
do_logmsg(LOG_WARNING, pr_fmt(fmt), ##__VA_ARGS__); \
85+
#define pr_warn(...) \
86+
do { \
87+
do_logmsg(LOG_WARNING, pr_prefix __VA_ARGS__); \
8888
} while (0)
8989

90-
#define pr_info(fmt, ...) \
91-
do { \
92-
do_logmsg(LOG_INFO, pr_fmt(fmt), ##__VA_ARGS__); \
90+
#define pr_info(...) \
91+
do { \
92+
do_logmsg(LOG_INFO, pr_prefix __VA_ARGS__); \
9393
} while (0)
9494

95-
#define pr_dbg(fmt, ...) \
96-
do { \
97-
do_logmsg(LOG_DEBUG, pr_fmt(fmt), ##__VA_ARGS__); \
95+
#define pr_dbg(...) \
96+
do { \
97+
do_logmsg(LOG_DEBUG, pr_prefix __VA_ARGS__); \
9898
} while (0)
9999

100-
#define dev_dbg(lvl, fmt, ...) \
100+
#define dev_dbg(lvl, ...) \
101101
do { \
102-
do_logmsg(lvl, pr_fmt(fmt), ##__VA_ARGS__); \
102+
do_logmsg(lvl, pr_prefix __VA_ARGS__); \
103103
} while (0)
104104

105105
#define panic(...) \

0 commit comments

Comments
 (0)