All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] tools: bpftool: move p_err() and p_info() from main.h to common.c
@ 2017-11-03 20:59 Jakub Kicinski
  2017-11-04  9:46 ` Alexei Starovoitov
  2017-11-05 13:29 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Jakub Kicinski @ 2017-11-03 20:59 UTC (permalink / raw)
  To: netdev; +Cc: oss-drivers, Quentin Monnet, Jakub Kicinski

From: Quentin Monnet <quentin.monnet@netronome.com>

The two functions were declared as static inline in a header file. There
is no particular reason why they should be inlined, they just happened to
remain in the same header file when they were turned from macros to
functions in a precious commit.

Make them non-inlined functions and move them to common.c file instead.

Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 tools/bpf/bpftool/common.c | 31 +++++++++++++++++++++++++++++++
 tools/bpf/bpftool/main.h   | 34 +++-------------------------------
 2 files changed, 34 insertions(+), 31 deletions(-)

diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c
index f0288269dae8..aa7017098b2a 100644
--- a/tools/bpf/bpftool/common.c
+++ b/tools/bpf/bpftool/common.c
@@ -50,6 +50,37 @@
 
 #include "main.h"
 
+void p_err(const char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	if (json_output) {
+		jsonw_start_object(json_wtr);
+		jsonw_name(json_wtr, "error");
+		jsonw_vprintf_enquote(json_wtr, fmt, ap);
+		jsonw_end_object(json_wtr);
+	} else {
+		fprintf(stderr, "Error: ");
+		vfprintf(stderr, fmt, ap);
+		fprintf(stderr, "\n");
+	}
+	va_end(ap);
+}
+
+void p_info(const char *fmt, ...)
+{
+	va_list ap;
+
+	if (json_output)
+		return;
+
+	va_start(ap, fmt);
+	vfprintf(stderr, fmt, ap);
+	fprintf(stderr, "\n");
+	va_end(ap);
+}
+
 static bool is_bpffs(char *path)
 {
 	struct statfs st_fs;
diff --git a/tools/bpf/bpftool/main.h b/tools/bpf/bpftool/main.h
index d315d01be645..ff5ad05b137b 100644
--- a/tools/bpf/bpftool/main.h
+++ b/tools/bpf/bpftool/main.h
@@ -71,6 +71,9 @@ extern const char *bin_name;
 extern json_writer_t *json_wtr;
 extern bool json_output;
 
+void p_err(const char *fmt, ...);
+void p_info(const char *fmt, ...);
+
 bool is_prefix(const char *pfx, const char *str);
 void fprint_hex(FILE *f, void *arg, unsigned int n, const char *sep);
 void usage(void) __attribute__((noreturn));
@@ -97,35 +100,4 @@ int prog_parse_fd(int *argc, char ***argv);
 void disasm_print_insn(unsigned char *image, ssize_t len, int opcodes);
 void print_hex_data_json(uint8_t *data, size_t len);
 
-static inline void p_err(const char *fmt, ...)
-{
-	va_list ap;
-
-	va_start(ap, fmt);
-	if (json_output) {
-		jsonw_start_object(json_wtr);
-		jsonw_name(json_wtr, "error");
-		jsonw_vprintf_enquote(json_wtr, fmt, ap);
-		jsonw_end_object(json_wtr);
-	} else {
-		fprintf(stderr, "Error: ");
-		vfprintf(stderr, fmt, ap);
-		fprintf(stderr, "\n");
-	}
-	va_end(ap);
-}
-
-static inline void p_info(const char *fmt, ...)
-{
-	va_list ap;
-
-	if (json_output)
-		return;
-
-	va_start(ap, fmt);
-	vfprintf(stderr, fmt, ap);
-	fprintf(stderr, "\n");
-	va_end(ap);
-}
-
 #endif
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] tools: bpftool: move p_err() and p_info() from main.h to common.c
  2017-11-03 20:59 [PATCH net-next] tools: bpftool: move p_err() and p_info() from main.h to common.c Jakub Kicinski
@ 2017-11-04  9:46 ` Alexei Starovoitov
  2017-11-05 13:29 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Alexei Starovoitov @ 2017-11-04  9:46 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: netdev, oss-drivers, Quentin Monnet

On Fri, Nov 03, 2017 at 01:59:07PM -0700, Jakub Kicinski wrote:
> From: Quentin Monnet <quentin.monnet@netronome.com>
> 
> The two functions were declared as static inline in a header file. There
> is no particular reason why they should be inlined, they just happened to
> remain in the same header file when they were turned from macros to
> functions in a precious commit.
> 
> Make them non-inlined functions and move them to common.c file instead.
> 
> Suggested-by: Joe Perches <joe@perches.com>
> Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>

Acked-by: Alexei Starovoitov <ast@kernel.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] tools: bpftool: move p_err() and p_info() from main.h to common.c
  2017-11-03 20:59 [PATCH net-next] tools: bpftool: move p_err() and p_info() from main.h to common.c Jakub Kicinski
  2017-11-04  9:46 ` Alexei Starovoitov
@ 2017-11-05 13:29 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-11-05 13:29 UTC (permalink / raw)
  To: jakub.kicinski; +Cc: netdev, oss-drivers, quentin.monnet

From: Jakub Kicinski <jakub.kicinski@netronome.com>
Date: Fri,  3 Nov 2017 13:59:07 -0700

> From: Quentin Monnet <quentin.monnet@netronome.com>
> 
> The two functions were declared as static inline in a header file. There
> is no particular reason why they should be inlined, they just happened to
> remain in the same header file when they were turned from macros to
> functions in a precious commit.
> 
> Make them non-inlined functions and move them to common.c file instead.
> 
> Suggested-by: Joe Perches <joe@perches.com>
> Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-11-05 13:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-03 20:59 [PATCH net-next] tools: bpftool: move p_err() and p_info() from main.h to common.c Jakub Kicinski
2017-11-04  9:46 ` Alexei Starovoitov
2017-11-05 13:29 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.