public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] json_print: fix print_uint with helper type extensions
Date: Fri, 16 Mar 2018 13:34:37 -0700	[thread overview]
Message-ID: <20180316133437.5f535a0e@xeon-e3> (raw)
In-Reply-To: <20180315200720.829-1-ldir@darbyshire-bryant.me.uk>

On Thu, 15 Mar 2018 20:07:20 +0000
Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk> wrote:

> Introduce print helper functions for int, uint, explicit int32, uint32,
> int64 & uint64.
> 
> print_int used 'int' type internally, whereas print_uint used 'uint64_t'
> 
> These helper functions eventually call vfprintf(fp, fmt, args) which is
> a variable argument list function and is dependent upon 'fmt' containing
> correct information about the length of the passed arguments.
> 
> Unfortunately print_int v print_uint offered no clue to the programmer
> that internally passed ints to print_uint were being promoted to 64bits,
> thus the format passed in 'fmt' string vs the actual passed integer
> could be different lengths.  This is even more interesting on big endian
> architectures where 'vfprintf' would be looking in the middle of an
> int64 type and hence produced wildly incorrect values in tc qdisc
> output.
> 
> print_u/int now stick with native int size.  print_u/int32 & print
> u/int64 functions offer explicit integer sizes.
> 
> To portably use these formats you should use the relevant PRIdN or PRIuN
> formats as defined in inttypes.h
> 
> e.g.
> 
> print_uint64(PRINT_ANY, "refcnt", "refcnt %" PRIu64 " ", t->tcm_info)
> 
> Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>

I am fine with this. But since there is no code using it yet, it should
go net-next branch.

Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>

  reply	other threads:[~2018-03-16 20:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-15 20:07 [PATCH] json_print: fix print_uint with helper type extensions Kevin Darbyshire-Bryant
2018-03-16 20:34 ` Stephen Hemminger [this message]
2018-03-18  8:40   ` Kevin Darbyshire-Bryant
2018-03-26 15:03     ` David Ahern
2018-03-29 19:33       ` Kevin Darbyshire-Bryant

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=20180316133437.5f535a0e@xeon-e3 \
    --to=stephen@networkplumber.org \
    --cc=ldir@darbyshire-bryant.me.uk \
    --cc=netdev@vger.kernel.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