All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Alejandro Vallejo <alejandro.vallejo@cloud.com>
Cc: Ross Lagerwall <ross.lagerwall@cloud.com>,
	xen-devel@lists.xenproject.org,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: Re: [PATCH 1/2] livepatch-build-tools: remove usage of gawk
Date: Mon, 27 Nov 2023 15:47:53 +0100	[thread overview]
Message-ID: <ZWSsGfEx-F5yyRU8@macbook> (raw)
In-Reply-To: <3706e5a8-7893-4e4e-a9b2-60517720f2a7@cloud.com>

On Fri, Nov 24, 2023 at 12:10:57PM +0000, Alejandro Vallejo wrote:
> On 24/11/2023 11:43, Ross Lagerwall wrote:
> > On Thu, Nov 23, 2023 at 4:08 PM Roger Pau Monne <roger.pau@citrix.com>
> wrote:
> >>
> >> And instead use plain awk.
> >>
> >> There's no need to use the --non-decimal-data option for gawk, since the
> >> numbers that we want to print are already prefixed with '0x', and so
> plain awk
> >> will do the conversion from hexadecimal to decimal just fine.
> >
> > I don't think that's true (at least with gnu awk 5.1.1):
> >
> > $ echo '<e98b7>   DW_AT_byte_size   : 0x14' | awk '{printf("%d\n", $4)}'
> > 0
> >
> 
> I think it's a FreeBSD quirk. From their man page:

Seems like BusyBox inherited that behavior:

BusyBox v1.36.1 (2023-07-27 17:12:24 UTC) multi-call binary.
$ echo '<e98b7>   DW_AT_byte_size   : 0x14' | awk '{printf("%d\n", $4)}'
20

I've assumed that Busybox was the lowest common denominator, but not
in this case.

> >        Historically,  awk did not accept "0x" as a hex string. However,
> since
> >        One True Awk used strtod to convert strings to floats, and since
> "0x12"
> >        is a valid hexadecimal representation of a floating  point number,
> On
> >        FreeBSD, awk has accepted this notation as an extension since One
> True
> >        Awk was imported in FreeBSD 5.0. Upstream One True  Awk has
> restored
> >        the  historical behavior for better compatibility between the
> different
> >        awk implementations.  Both gawk and mawk already  behave similarly.
> >        Starting with FreeBSD 14.0 awk will no longer accept this
> extension.
> 
> I'm guessing the latest FreeBSD doesn't have that behaviour either?

Hm, I guess my FreeBSD world is not new enough, as the awk (version
20210724) I have does parse hex numbers:

# echo '<e98b7>   DW_AT_byte_size   : 0x14' | awk '{printf("%d\n", $4)}'
20

Will see what I can do to address this without requiring gawk if
possible.

I'm not sure if there are other issues that would prevent
livepatch-build-tools from working on FreeBSD however.

Thanks, Roger.


  reply	other threads:[~2023-11-27 14:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-23 16:05 [PATCH 0/2] livepatch-build-tools: fixes for non GNU tools Roger Pau Monne
2023-11-23 16:05 ` [PATCH 1/2] livepatch-build-tools: remove usage of gawk Roger Pau Monne
2023-11-24 11:43   ` Ross Lagerwall
2023-11-24 12:10     ` Alejandro Vallejo
2023-11-27 14:47       ` Roger Pau Monné [this message]
2023-11-23 16:05 ` [PATCH 2/2] livepatch-build-tools: do not use readlink -m option Roger Pau Monne
2023-11-24 12:02   ` Ross Lagerwall

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=ZWSsGfEx-F5yyRU8@macbook \
    --to=roger.pau@citrix.com \
    --cc=alejandro.vallejo@cloud.com \
    --cc=konrad.wilk@oracle.com \
    --cc=ross.lagerwall@cloud.com \
    --cc=xen-devel@lists.xenproject.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 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.