[dpdk-dev,v3,01/20] kvargs: remove rte log dependency

Message ID 86805efc91737ce4ae2b864cadf1508ecd7954f0.1522105876.git.gaetan.rivet@6wind.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Gaëtan Rivet March 26, 2018, 11:18 p.m. UTC
  Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_kvargs/rte_kvargs.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
  

Comments

Neil Horman March 27, 2018, 6:19 p.m. UTC | #1
On Tue, Mar 27, 2018 at 01:18:25AM +0200, Gaetan Rivet wrote:
> Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
> ---
>  lib/librte_kvargs/rte_kvargs.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/librte_kvargs/rte_kvargs.c b/lib/librte_kvargs/rte_kvargs.c
> index 9662375e8..d6b187aac 100644
> --- a/lib/librte_kvargs/rte_kvargs.c
> +++ b/lib/librte_kvargs/rte_kvargs.c
> @@ -3,10 +3,10 @@
>   * Copyright(c) 2014 6WIND S.A.
>   */
>  
> +#include <stdio.h>
>  #include <string.h>
>  #include <stdlib.h>
>  
> -#include <rte_log.h>
>  #include <rte_string_fns.h>
>  
>  #include "rte_kvargs.h"
> @@ -29,7 +29,7 @@ rte_kvargs_tokenize(struct rte_kvargs *kvlist, const char *params)
>  	 */
>  	kvlist->str = strdup(params);
>  	if (kvlist->str == NULL) {
> -		RTE_LOG(ERR, PMD, "Cannot parse arguments: not enough memory\n");
> +		fprintf(stderr, "Cannot parse arguments: not enough memory\n");
>  		return -1;
>  	}
>  
I'm not entirely sure why any of this is needed.  RTE_LOG is basically a wrapper
around rte_vlog, which has this block of code:

if (f == NULL) {
                f = default_log_stream;
                if (f == NULL) {
                        /*
                         * Grab the current value of stderr here, rather than
                         * just initializing default_log_stream to stderr. This
                         * ensures that we will always use the current value
                         * of stderr, even if the application closes and
                         * reopens it.
                         */
                        f = stderr;
                }
        }
}

It seems to me that if rte_log_openstream hasn't been called yet, we should just
dump messages to stderr, just like Keith noted in his other email.  If thats not
working, thats definately a problem, but regardless, you should be able to use
RTE_LOG in your code without issue.

Neil
  

Patch

diff --git a/lib/librte_kvargs/rte_kvargs.c b/lib/librte_kvargs/rte_kvargs.c
index 9662375e8..d6b187aac 100644
--- a/lib/librte_kvargs/rte_kvargs.c
+++ b/lib/librte_kvargs/rte_kvargs.c
@@ -3,10 +3,10 @@ 
  * Copyright(c) 2014 6WIND S.A.
  */
 
+#include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 
-#include <rte_log.h>
 #include <rte_string_fns.h>
 
 #include "rte_kvargs.h"
@@ -29,7 +29,7 @@  rte_kvargs_tokenize(struct rte_kvargs *kvlist, const char *params)
 	 */
 	kvlist->str = strdup(params);
 	if (kvlist->str == NULL) {
-		RTE_LOG(ERR, PMD, "Cannot parse arguments: not enough memory\n");
+		fprintf(stderr, "Cannot parse arguments: not enough memory\n");
 		return -1;
 	}
 
@@ -39,14 +39,14 @@  rte_kvargs_tokenize(struct rte_kvargs *kvlist, const char *params)
 
 		i = kvlist->count;
 		if (i >= RTE_KVARGS_MAX) {
-			RTE_LOG(ERR, PMD, "Cannot parse arguments: list full\n");
+			fprintf(stderr, "Cannot parse arguments: list full\n");
 			return -1;
 		}
 
 		kvlist->pairs[i].key = strtok_r(str, RTE_KVARGS_KV_DELIM, &ctx2);
 		kvlist->pairs[i].value = strtok_r(NULL, RTE_KVARGS_KV_DELIM, &ctx2);
 		if (kvlist->pairs[i].key == NULL || kvlist->pairs[i].value == NULL) {
-			RTE_LOG(ERR, PMD,
+			fprintf(stderr,
 				"Cannot parse arguments: wrong key or value\n"
 				"params=<%s>\n", params);
 			return -1;
@@ -90,7 +90,7 @@  check_for_valid_keys(struct rte_kvargs *kvlist,
 		pair = &kvlist->pairs[i];
 		ret = is_valid_key(valid, pair->key);
 		if (!ret) {
-			RTE_LOG(ERR, PMD,
+			fprintf(stderr,
 				"Error parsing device, invalid key <%s>\n",
 				pair->key);
 			return -1;