* [PATCH iproute2-next 1/2] tc: replace print_string with fprintf for error messages
@ 2019-01-24 20:30 Stephen Hemminger
2019-01-24 20:30 ` [PATCH iproute2-next 2/2] tc: replace left side comparison Stephen Hemminger
2019-01-28 16:53 ` [PATCH iproute2-next 1/2] tc: replace print_string with fprintf for error messages David Ahern
0 siblings, 2 replies; 4+ messages in thread
From: Stephen Hemminger @ 2019-01-24 20:30 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
Any error output should go to standard error.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
tc/f_matchall.c | 2 +-
tc/m_connmark.c | 2 +-
tc/m_csum.c | 2 +-
tc/m_gact.c | 2 +-
tc/m_ife.c | 2 +-
tc/m_mirred.c | 2 +-
tc/m_nat.c | 2 +-
tc/m_sample.c | 2 +-
tc/m_skbedit.c | 2 +-
tc/m_vlan.c | 2 +-
10 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/tc/f_matchall.c b/tc/f_matchall.c
index 03dd51de1ace..59f452c5361e 100644
--- a/tc/f_matchall.c
+++ b/tc/f_matchall.c
@@ -146,7 +146,7 @@ static int matchall_print_opt(struct filter_util *qu, FILE *f,
if (tb[TCA_MATCHALL_PCNT]) {
if (RTA_PAYLOAD(tb[TCA_MATCHALL_PCNT]) < sizeof(*pf)) {
- print_string(PRINT_FP, NULL, "Broken perf counters\n", NULL);
+ fprintf(stderr, "Performance counter size mismatch\n");
return -1;
}
pf = RTA_DATA(tb[TCA_MATCHALL_PCNT]);
diff --git a/tc/m_connmark.c b/tc/m_connmark.c
index 45e2d05f1a91..34d80b1a27c0 100644
--- a/tc/m_connmark.c
+++ b/tc/m_connmark.c
@@ -114,7 +114,7 @@ static int print_connmark(struct action_util *au, FILE *f, struct rtattr *arg)
parse_rtattr_nested(tb, TCA_CONNMARK_MAX, arg);
if (tb[TCA_CONNMARK_PARMS] == NULL) {
- print_string(PRINT_FP, NULL, "%s", "[NULL connmark parameters]");
+ fprintf(stderr, "NULL connmark parameters\n");
return -1;
}
diff --git a/tc/m_csum.c b/tc/m_csum.c
index 752269d1d020..450f2b557b44 100644
--- a/tc/m_csum.c
+++ b/tc/m_csum.c
@@ -172,7 +172,7 @@ print_csum(struct action_util *au, FILE *f, struct rtattr *arg)
parse_rtattr_nested(tb, TCA_CSUM_MAX, arg);
if (tb[TCA_CSUM_PARMS] == NULL) {
- fprintf(f, "[NULL csum parameters]");
+ fprintf(stderr, "missing csum parameters\n");
return -1;
}
sel = RTA_DATA(tb[TCA_CSUM_PARMS]);
diff --git a/tc/m_gact.c b/tc/m_gact.c
index a0a3c33d23da..342927bc2ed7 100644
--- a/tc/m_gact.c
+++ b/tc/m_gact.c
@@ -174,7 +174,7 @@ print_gact(struct action_util *au, FILE *f, struct rtattr *arg)
parse_rtattr_nested(tb, TCA_GACT_MAX, arg);
if (tb[TCA_GACT_PARMS] == NULL) {
- print_string(PRINT_FP, NULL, "%s", "[NULL gact parameters]");
+ fprintf(stderr, "[NULL gact parameters]\n");
return -1;
}
p = RTA_DATA(tb[TCA_GACT_PARMS]);
diff --git a/tc/m_ife.c b/tc/m_ife.c
index 2bf9f2047b46..b754cfc3a03a 100644
--- a/tc/m_ife.c
+++ b/tc/m_ife.c
@@ -234,7 +234,7 @@ static int print_ife(struct action_util *au, FILE *f, struct rtattr *arg)
parse_rtattr_nested(tb, TCA_IFE_MAX, arg);
if (tb[TCA_IFE_PARMS] == NULL) {
- print_string(PRINT_FP, NULL, "%s", "[NULL ife parameters]");
+ fprintf(stderr, "[NULL ife parameters]\n");
return -1;
}
p = RTA_DATA(tb[TCA_IFE_PARMS]);
diff --git a/tc/m_mirred.c b/tc/m_mirred.c
index c7f7318b8413..fb4cab5fb9eb 100644
--- a/tc/m_mirred.c
+++ b/tc/m_mirred.c
@@ -286,7 +286,7 @@ print_mirred(struct action_util *au, FILE *f, struct rtattr *arg)
parse_rtattr_nested(tb, TCA_MIRRED_MAX, arg);
if (tb[TCA_MIRRED_PARMS] == NULL) {
- print_string(PRINT_FP, NULL, "%s", "[NULL mirred parameters]");
+ fprintf(stderr, "mirred parameters missing\n");
return -1;
}
p = RTA_DATA(tb[TCA_MIRRED_PARMS]);
diff --git a/tc/m_nat.c b/tc/m_nat.c
index ee0b7520a605..4cd255299ccb 100644
--- a/tc/m_nat.c
+++ b/tc/m_nat.c
@@ -152,7 +152,7 @@ print_nat(struct action_util *au, FILE * f, struct rtattr *arg)
parse_rtattr_nested(tb, TCA_NAT_MAX, arg);
if (tb[TCA_NAT_PARMS] == NULL) {
- print_string(PRINT_FP, NULL, "%s", "[NULL nat parameters]");
+ fprintf(stderr, "[NULL nat parameters]\n");
return -1;
}
sel = RTA_DATA(tb[TCA_NAT_PARMS]);
diff --git a/tc/m_sample.c b/tc/m_sample.c
index 39a99246a8ea..2af098ecba90 100644
--- a/tc/m_sample.c
+++ b/tc/m_sample.c
@@ -149,7 +149,7 @@ static int print_sample(struct action_util *au, FILE *f, struct rtattr *arg)
if (!tb[TCA_SAMPLE_PARMS] || !tb[TCA_SAMPLE_RATE] ||
!tb[TCA_SAMPLE_PSAMPLE_GROUP]) {
- print_string(PRINT_FP, NULL, "%s", "[NULL sample parameters]");
+ fprintf(stderr, "[NULL sample parameters]\n");
return -1;
}
p = RTA_DATA(tb[TCA_SAMPLE_PARMS]);
diff --git a/tc/m_skbedit.c b/tc/m_skbedit.c
index b6b839f8ef6c..ee0cd987fa3a 100644
--- a/tc/m_skbedit.c
+++ b/tc/m_skbedit.c
@@ -186,7 +186,7 @@ static int print_skbedit(struct action_util *au, FILE *f, struct rtattr *arg)
parse_rtattr_nested(tb, TCA_SKBEDIT_MAX, arg);
if (tb[TCA_SKBEDIT_PARMS] == NULL) {
- print_string(PRINT_FP, NULL, "%s", "[NULL skbedit parameters]");
+ fprintf(stderr, "[NULL skbedit parameters]\n");
return -1;
}
p = RTA_DATA(tb[TCA_SKBEDIT_PARMS]);
diff --git a/tc/m_vlan.c b/tc/m_vlan.c
index 412f6aa1000e..f58bbf0a0320 100644
--- a/tc/m_vlan.c
+++ b/tc/m_vlan.c
@@ -188,7 +188,7 @@ static int print_vlan(struct action_util *au, FILE *f, struct rtattr *arg)
parse_rtattr_nested(tb, TCA_VLAN_MAX, arg);
if (!tb[TCA_VLAN_PARMS]) {
- print_string(PRINT_FP, NULL, "%s", "[NULL vlan parameters]");
+ fprintf(stderr, "[NULL vlan parameters]\n");
return -1;
}
parm = RTA_DATA(tb[TCA_VLAN_PARMS]);
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH iproute2-next 2/2] tc: replace left side comparison
2019-01-24 20:30 [PATCH iproute2-next 1/2] tc: replace print_string with fprintf for error messages Stephen Hemminger
@ 2019-01-24 20:30 ` Stephen Hemminger
2019-01-28 16:51 ` David Ahern
2019-01-28 16:53 ` [PATCH iproute2-next 1/2] tc: replace print_string with fprintf for error messages David Ahern
1 sibling, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2019-01-24 20:30 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
The kernel (and iproute2) don't use the if (NULL == x) style
and instead prefer if (!x)
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
tc/m_action.c | 2 +-
tc/m_ipt.c | 3 +--
tc/m_xt_old.c | 3 +--
tc/tc_util.c | 2 +-
4 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/tc/m_action.c b/tc/m_action.c
index d5fd5affe703..b5aff3ab4896 100644
--- a/tc/m_action.c
+++ b/tc/m_action.c
@@ -363,7 +363,7 @@ tc_print_action(FILE *f, const struct rtattr *arg, unsigned short tot_acts)
parse_rtattr_nested(tb, tot_acts, arg);
- if (tab_flush && NULL != tb[0] && NULL == tb[1])
+ if (tab_flush && tb[0] && !tb[1])
return tc_print_action_flush(f, tb[0]);
open_json_array(PRINT_JSON, "actions");
diff --git a/tc/m_ipt.c b/tc/m_ipt.c
index b48cc0a9c85f..1d73cb98895a 100644
--- a/tc/m_ipt.c
+++ b/tc/m_ipt.c
@@ -299,9 +299,8 @@ static int parse_ipt(struct action_util *a, int *argc_p,
int i;
for (i = 0; i < rargc; i++) {
- if (NULL == argv[i] || 0 == strcmp(argv[i], "action")) {
+ if (!argv[i] || strcmp(argv[i], "action") == 0)
break;
- }
}
iargc = argc = i;
}
diff --git a/tc/m_xt_old.c b/tc/m_xt_old.c
index 313bea61cc7e..25d367785786 100644
--- a/tc/m_xt_old.c
+++ b/tc/m_xt_old.c
@@ -224,9 +224,8 @@ static int parse_ipt(struct action_util *a, int *argc_p,
int i;
for (i = 0; i < rargc; i++) {
- if (NULL == argv[i] || 0 == strcmp(argv[i], "action")) {
+ if (!argv[i] || strcmp(argv[i], "action") == 0)
break;
- }
}
iargc = argc = i;
}
diff --git a/tc/tc_util.c b/tc/tc_util.c
index ab717890bb2a..1dfdae141f4d 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -857,7 +857,7 @@ void print_tcstats_attr(FILE *fp, struct rtattr *tb[], char *prefix, struct rtat
if (tb[TCA_STATS2]) {
print_tcstats2_attr(fp, tb[TCA_STATS2], prefix, xstats);
- if (xstats && NULL == *xstats)
+ if (xstats && !*xstats)
goto compat_xstats;
return;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH iproute2-next 2/2] tc: replace left side comparison
2019-01-24 20:30 ` [PATCH iproute2-next 2/2] tc: replace left side comparison Stephen Hemminger
@ 2019-01-28 16:51 ` David Ahern
0 siblings, 0 replies; 4+ messages in thread
From: David Ahern @ 2019-01-28 16:51 UTC (permalink / raw)
To: Stephen Hemminger, netdev
On 1/24/19 1:30 PM, Stephen Hemminger wrote:
> The kernel (and iproute2) don't use the if (NULL == x) style
> and instead prefer if (!x)
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> tc/m_action.c | 2 +-
> tc/m_ipt.c | 3 +--
> tc/m_xt_old.c | 3 +--
> tc/tc_util.c | 2 +-
> 4 files changed, 4 insertions(+), 6 deletions(-)
>
applied to iproute2-next. Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH iproute2-next 1/2] tc: replace print_string with fprintf for error messages
2019-01-24 20:30 [PATCH iproute2-next 1/2] tc: replace print_string with fprintf for error messages Stephen Hemminger
2019-01-24 20:30 ` [PATCH iproute2-next 2/2] tc: replace left side comparison Stephen Hemminger
@ 2019-01-28 16:53 ` David Ahern
1 sibling, 0 replies; 4+ messages in thread
From: David Ahern @ 2019-01-28 16:53 UTC (permalink / raw)
To: Stephen Hemminger, netdev
On 1/24/19 1:30 PM, Stephen Hemminger wrote:
> diff --git a/tc/m_connmark.c b/tc/m_connmark.c
> index 45e2d05f1a91..34d80b1a27c0 100644
> --- a/tc/m_connmark.c
> +++ b/tc/m_connmark.c
> @@ -114,7 +114,7 @@ static int print_connmark(struct action_util *au, FILE *f, struct rtattr *arg)
>
> parse_rtattr_nested(tb, TCA_CONNMARK_MAX, arg);
> if (tb[TCA_CONNMARK_PARMS] == NULL) {
> - print_string(PRINT_FP, NULL, "%s", "[NULL connmark parameters]");
> + fprintf(stderr, "NULL connmark parameters\n");
> return -1;
> }
>
> diff --git a/tc/m_csum.c b/tc/m_csum.c
> index 752269d1d020..450f2b557b44 100644
> --- a/tc/m_csum.c
> +++ b/tc/m_csum.c
> @@ -172,7 +172,7 @@ print_csum(struct action_util *au, FILE *f, struct rtattr *arg)
> parse_rtattr_nested(tb, TCA_CSUM_MAX, arg);
>
> if (tb[TCA_CSUM_PARMS] == NULL) {
> - fprintf(f, "[NULL csum parameters]");
> + fprintf(stderr, "missing csum parameters\n");
> return -1;
> }
> sel = RTA_DATA(tb[TCA_CSUM_PARMS]);
> diff --git a/tc/m_gact.c b/tc/m_gact.c
> index a0a3c33d23da..342927bc2ed7 100644
> --- a/tc/m_gact.c
> +++ b/tc/m_gact.c
> @@ -174,7 +174,7 @@ print_gact(struct action_util *au, FILE *f, struct rtattr *arg)
> parse_rtattr_nested(tb, TCA_GACT_MAX, arg);
>
> if (tb[TCA_GACT_PARMS] == NULL) {
> - print_string(PRINT_FP, NULL, "%s", "[NULL gact parameters]");
> + fprintf(stderr, "[NULL gact parameters]\n");
We should be consistent and not showing the the '[]'. You have several
error messages with those included.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-01-28 16:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-24 20:30 [PATCH iproute2-next 1/2] tc: replace print_string with fprintf for error messages Stephen Hemminger
2019-01-24 20:30 ` [PATCH iproute2-next 2/2] tc: replace left side comparison Stephen Hemminger
2019-01-28 16:51 ` David Ahern
2019-01-28 16:53 ` [PATCH iproute2-next 1/2] tc: replace print_string with fprintf for error messages David Ahern
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).