From: Stephen Hemminger <stephen@networkplumber.org>
To: cristian.dumitrescu@intel.com
Cc: dev@dpdk.org, Stephen Hemminger <stephen@networkplumber.org>
Subject: [dpdk-dev] [PATCH 2/3] cfgfile: use RTE_LOG for errors
Date: Tue, 16 Jul 2019 10:27:40 -0700 [thread overview]
Message-ID: <20190716172741.21399-3-stephen@networkplumber.org> (raw)
In-Reply-To: <20190716172741.21399-1-stephen@networkplumber.org>
In general, DPDK libraries to not print error messages to
stdout because that is often redirected to /dev/null for daemons.
This patch changes cfgfile library to use RTE_LOG with its
own type.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/librte_cfgfile/rte_cfgfile.c | 25 +++++++++++++++----------
lib/librte_eal/common/include/rte_log.h | 1 +
2 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c
index 1ef298592fa5..c4b768b6833f 100644
--- a/lib/librte_cfgfile/rte_cfgfile.c
+++ b/lib/librte_cfgfile/rte_cfgfile.c
@@ -9,6 +9,7 @@
#include <errno.h>
#include <rte_string_fns.h>
#include <rte_common.h>
+#include <rte_log.h>
#include "rte_cfgfile.h"
@@ -128,7 +129,7 @@ rte_cfgfile_check_params(const struct rte_cfgfile_parameters *params)
unsigned int i;
if (!params) {
- printf("Error - missing cfgfile parameters\n");
+ RTE_LOG(ERR, CFGFILE, "missing cfgfile parameters\n");
return -EINVAL;
}
@@ -141,7 +142,7 @@ rte_cfgfile_check_params(const struct rte_cfgfile_parameters *params)
}
if (valid_comment == 0) {
- printf("Error - invalid comment characters %c\n",
+ RTE_LOG(ERR, CFGFILE, "invalid comment characters %c\n",
params->comment_character);
return -ENOTSUP;
}
@@ -178,7 +179,7 @@ rte_cfgfile_load_with_params(const char *filename, int flags,
size_t len = strnlen(buffer, sizeof(buffer));
lineno++;
if ((len >= sizeof(buffer) - 1) && (buffer[len-1] != '\n')) {
- printf("Error line %d - no \\n found on string. "
+ RTE_LOG(ERR, CFGFILE, " line %d - no \\n found on string. "
"Check if line too long\n", lineno);
goto error1;
}
@@ -198,8 +199,9 @@ rte_cfgfile_load_with_params(const char *filename, int flags,
/* section heading line */
char *end = memchr(buffer, ']', len);
if (end == NULL) {
- printf("Error line %d - no terminating ']'"
- "character found\n", lineno);
+ RTE_LOG(ERR, CFGFILE,
+ "line %d - no terminating ']' character found\n",
+ lineno);
goto error1;
}
*end = '\0';
@@ -213,8 +215,9 @@ rte_cfgfile_load_with_params(const char *filename, int flags,
split[0] = buffer;
split[1] = memchr(buffer, '=', len);
if (split[1] == NULL) {
- printf("Error line %d - no '='"
- "character found\n", lineno);
+ RTE_LOG(ERR, CFGFILE,
+ "line %d - no '=' character found\n",
+ lineno);
goto error1;
}
*split[1] = '\0';
@@ -236,8 +239,9 @@ rte_cfgfile_load_with_params(const char *filename, int flags,
if (!(flags & CFG_FLAG_EMPTY_VALUES) &&
(*split[1] == '\0')) {
- printf("Error at line %d - cannot use empty "
- "values\n", lineno);
+ RTE_LOG(ERR, CFGFILE,
+ "line %d - cannot use empty values\n",
+ lineno);
goto error1;
}
@@ -397,7 +401,8 @@ int rte_cfgfile_set_entry(struct rte_cfgfile *cfg, const char *sectionname,
sizeof(curr_section->entries[i].value));
return 0;
}
- printf("Error - entry name doesn't exist\n");
+
+ RTE_LOG(ERR, CFGFILE, "entry name doesn't exist\n");
return -EINVAL;
}
diff --git a/lib/librte_eal/common/include/rte_log.h b/lib/librte_eal/common/include/rte_log.h
index cbb41846aaa3..fa747d5b90ef 100644
--- a/lib/librte_eal/common/include/rte_log.h
+++ b/lib/librte_eal/common/include/rte_log.h
@@ -62,6 +62,7 @@ extern struct rte_logs rte_logs;
#define RTE_LOGTYPE_EFD 18 /**< Log related to EFD. */
#define RTE_LOGTYPE_EVENTDEV 19 /**< Log related to eventdev. */
#define RTE_LOGTYPE_GSO 20 /**< Log related to GSO. */
+#define RTE_LOGTYPE_CFGFILE 21 /**< Log related to cfgfile. */
/* these log types can be used in an application */
#define RTE_LOGTYPE_USER1 24 /**< User-defined log type 1. */
--
2.20.1
next prev parent reply other threads:[~2019-07-16 17:28 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-16 17:27 [dpdk-dev] [PATCH 0/3] cfgfile: cleanup patches Stephen Hemminger
2019-07-16 17:27 ` [dpdk-dev] [PATCH 1/3] cfgfile: remove unnecessary initialization Stephen Hemminger
2019-07-16 17:27 ` Stephen Hemminger [this message]
2019-07-17 21:01 ` [dpdk-dev] [PATCH 2/3] cfgfile: use RTE_LOG for errors Thomas Monjalon
2019-07-17 22:10 ` Stephen Hemminger
2019-07-16 17:27 ` [dpdk-dev] [PATCH 3/3] cfgfile: use calloc Stephen Hemminger
2019-07-17 13:38 ` [dpdk-dev] [PATCH 0/3] cfgfile: cleanup patches Bruce Richardson
2019-07-18 0:48 ` [dpdk-dev] [PATCH v2 " Stephen Hemminger
2019-07-18 0:48 ` [dpdk-dev] [PATCH v2 1/3] cfgfile: remove unnecessary initialization Stephen Hemminger
2019-07-18 0:48 ` [dpdk-dev] [PATCH v2 2/3] cfgfile: use RTE_LOG for errors Stephen Hemminger
2019-07-18 8:31 ` Bruce Richardson
2019-07-18 14:34 ` Stephen Hemminger
2019-07-18 14:36 ` Bruce Richardson
2019-07-18 14:41 ` Stephen Hemminger
2019-07-18 17:12 ` Stephen Hemminger
2019-07-18 0:48 ` [dpdk-dev] [PATCH v2 3/3] cfgfile: use calloc Stephen Hemminger
2019-07-18 17:18 ` [dpdk-dev] [PATCH v3 0/3] cfgfile: cleanup patches Stephen Hemminger
2019-07-18 17:18 ` [dpdk-dev] [PATCH v3 1/3] cfgfile: remove unnecessary initialization Stephen Hemminger
2019-07-18 17:18 ` [dpdk-dev] [PATCH v3 2/3] cfgfile: use RTE_LOG for errors Stephen Hemminger
2019-07-18 22:39 ` Thomas Monjalon
2019-07-18 17:18 ` [dpdk-dev] [PATCH v3 3/3] cfgfile: use calloc Stephen Hemminger
2019-07-18 22:44 ` [dpdk-dev] [PATCH v3 0/3] cfgfile: cleanup patches Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190716172741.21399-3-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=cristian.dumitrescu@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).