From 826f541e51c02930796a93d03d15655c4c938025 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Wed, 11 Dec 2024 00:54:21 +0900 Subject: [PATCH] log.h: add WARN Fix issue 107 Signed-off-by: Akihiro Suda --- cli.c | 2 +- log.h | 3 +++ main.c | 6 ++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cli.c b/cli.c index 7ea4fac..2226a1e 100644 --- a/cli.c +++ b/cli.c @@ -195,7 +195,7 @@ struct cli_options *cli_options_parse(int argc, char *argv[]) { } if (res->vmnet_gateway == NULL) { if (res->vmnet_mode != VMNET_BRIDGED_MODE) { - ERROR("WARNING: --vmnet-gateway=IP should be explicitly specified to " + WARN("--vmnet-gateway=IP should be explicitly specified to " "avoid conflicting with other applications"); } if (res->vmnet_dhcp_end != NULL) { diff --git a/log.h b/log.h index 7c5059a..348e725 100644 --- a/log.h +++ b/log.h @@ -13,5 +13,8 @@ extern bool debug; #define ERROR(msg) fprintf(stderr, "ERROR| " msg "\n") #define ERRORF(fmt, ...) fprintf(stderr, "ERROR| " fmt "\n", __VA_ARGS__) #define ERRORN(name) ERRORF(name ": %s", strerror(errno)) +#define WARN(msg) fprintf(stderr, "WARN | " msg "\n") +#define WARNF(fmt, ...) fprintf(stderr, "WARN | " fmt "\n", __VA_ARGS__) + #endif /* SOCKET_VMNET_LOG_H */ diff --git a/main.c b/main.c index a05a2b0..628bb1c 100644 --- a/main.c +++ b/main.c @@ -400,12 +400,10 @@ int main(int argc, char *argv[]) { struct cli_options *cliopt = cli_options_parse(argc, argv); assert(cliopt != NULL); if (geteuid() != 0) { - ERROR("WARNING: Running without root. This is very unlikely to " - "work: See README.md"); + WARN("Running without root. This is very unlikely to work: See README.md"); } if (geteuid() != getuid()) { - ERROR("WARNING: Seems running with SETUID. This is insecure and " - "highly discouraged: See README.md"); + WARN("Seems running with SETUID. This is insecure and highly discouraged: See README.md"); } if (sigsetjmp(jmpbuf, 1) != 0) {