From: Stephen Hemminger <stephen@networkplumber.org>
To: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: dsahern@gmail.com, oss-drivers@netronome.com, netdev@vger.kernel.org
Subject: Re: [PATCH iproute2-next 2/8] json: add %hhu helpers
Date: Mon, 19 Nov 2018 17:18:42 -0800 [thread overview]
Message-ID: <20181119171842.1d1e94ad@xeon-e3> (raw)
In-Reply-To: <20181119230335.11771-3-jakub.kicinski@netronome.com>
On Mon, 19 Nov 2018 15:03:29 -0800
Jakub Kicinski <jakub.kicinski@netronome.com> wrote:
> Add helpers for printing char-size values.
>
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
> ---
> include/json_print.h | 1 +
> include/json_writer.h | 2 ++
> lib/json_print.c | 1 +
> lib/json_writer.c | 11 +++++++++++
> 4 files changed, 15 insertions(+)
>
> diff --git a/include/json_print.h b/include/json_print.h
> index 218da31a73fe..25954070db27 100644
> --- a/include/json_print.h
> +++ b/include/json_print.h
> @@ -64,6 +64,7 @@ _PRINT_FUNC(null, const char*);
> _PRINT_FUNC(string, const char*);
> _PRINT_FUNC(uint, unsigned int);
> _PRINT_FUNC(u64, uint64_t);
> +_PRINT_FUNC(hhu, unsigned char);
> _PRINT_FUNC(hu, unsigned short);
> _PRINT_FUNC(hex, unsigned int);
> _PRINT_FUNC(0xhex, unsigned long long int);
> diff --git a/include/json_writer.h b/include/json_writer.h
> index 0c8831c1136d..354c27541e89 100644
> --- a/include/json_writer.h
> +++ b/include/json_writer.h
> @@ -38,6 +38,7 @@ void jsonw_float_fmt(json_writer_t *self, const char *fmt, double num);
> void jsonw_uint(json_writer_t *self, unsigned int number);
> void jsonw_u64(json_writer_t *self, uint64_t number);
> void jsonw_xint(json_writer_t *self, uint64_t number);
> +void jsonw_hhu(json_writer_t *self, unsigned char num);
> void jsonw_hu(json_writer_t *self, unsigned short number);
> void jsonw_int(json_writer_t *self, int number);
> void jsonw_s64(json_writer_t *self, int64_t number);
> @@ -52,6 +53,7 @@ void jsonw_float_field(json_writer_t *self, const char *prop, double num);
> void jsonw_uint_field(json_writer_t *self, const char *prop, unsigned int num);
> void jsonw_u64_field(json_writer_t *self, const char *prop, uint64_t num);
> void jsonw_xint_field(json_writer_t *self, const char *prop, uint64_t num);
> +void jsonw_hhu_field(json_writer_t *self, const char *prop, unsigned char num);
> void jsonw_hu_field(json_writer_t *self, const char *prop, unsigned short num);
> void jsonw_int_field(json_writer_t *self, const char *prop, int num);
> void jsonw_s64_field(json_writer_t *self, const char *prop, int64_t num);
> diff --git a/lib/json_print.c b/lib/json_print.c
> index f7ef41c1570f..4f5fef195fde 100644
> --- a/lib/json_print.c
> +++ b/lib/json_print.c
> @@ -118,6 +118,7 @@ void close_json_array(enum output_type type, const char *str)
> }
> _PRINT_FUNC(int, int);
> _PRINT_FUNC(s64, int64_t);
> +_PRINT_FUNC(hhu, unsigned char);
> _PRINT_FUNC(hu, unsigned short);
> _PRINT_FUNC(uint, unsigned int);
> _PRINT_FUNC(u64, uint64_t);
> diff --git a/lib/json_writer.c b/lib/json_writer.c
> index 68890b34ee92..46eff6ad9828 100644
> --- a/lib/json_writer.c
> +++ b/lib/json_writer.c
> @@ -211,6 +211,11 @@ void jsonw_float(json_writer_t *self, double num)
> jsonw_printf(self, "%g", num);
> }
>
> +void jsonw_hhu(json_writer_t *self, unsigned char num)
> +{
> + jsonw_printf(self, "%hhu", num);
> +}
> +
> void jsonw_hu(json_writer_t *self, unsigned short num)
> {
> jsonw_printf(self, "%hu", num);
> @@ -288,6 +293,12 @@ void jsonw_xint_field(json_writer_t *self, const char *prop, uint64_t num)
> jsonw_xint(self, num);
> }
>
> +void jsonw_hhu_field(json_writer_t *self, const char *prop, unsigned char num)
> +{
> + jsonw_name(self, prop);
> + jsonw_hhu(self, num);
> +}
> +
> void jsonw_hu_field(json_writer_t *self, const char *prop, unsigned short num)
> {
> jsonw_name(self, prop);
Do you really need this? it turns out that because of C type conversions print_uint should just
work?
next prev parent reply other threads:[~2018-11-20 11:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-19 23:03 [PATCH iproute2-next 0/8] tc: gred: JSON-ify and support per-vq config Jakub Kicinski
2018-11-19 23:03 ` [PATCH iproute2-next 1/8] tc: gred: remove unclear comment Jakub Kicinski
2018-11-19 23:03 ` [PATCH iproute2-next 2/8] json: add %hhu helpers Jakub Kicinski
2018-11-20 1:18 ` Stephen Hemminger [this message]
2018-11-20 1:40 ` Jakub Kicinski
2018-11-20 23:18 ` David Ahern
2018-11-19 23:03 ` [PATCH iproute2-next 3/8] tc: move RED flag printing to helper Jakub Kicinski
2018-11-19 23:03 ` [PATCH iproute2-next 4/8] tc: gred: jsonify GRED output Jakub Kicinski
2018-11-19 23:03 ` [PATCH iproute2-next 5/8] tc: gred: separate out stats printing Jakub Kicinski
2018-11-19 23:03 ` [PATCH iproute2-next 6/8] tc: gred: use extended stats if available Jakub Kicinski
2018-11-19 23:03 ` [PATCH iproute2-next 7/8] tc: gred: support controlling RED flags Jakub Kicinski
2018-11-19 23:03 ` [PATCH iproute2-next 8/8] tc: gred: allow controlling and dumping per-DP " Jakub Kicinski
2018-11-24 15:26 ` [PATCH iproute2-next 0/8] tc: gred: JSON-ify and support per-vq config David Ahern
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=20181119171842.1d1e94ad@xeon-e3 \
--to=stephen@networkplumber.org \
--cc=dsahern@gmail.com \
--cc=jakub.kicinski@netronome.com \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@netronome.com \
/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).