Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Nov 2023 16:07:40 +0000
From:      Jessica Clarke <jrtc27@freebsd.org>
To:        "Jonathan T. Looney" <jtl@FreeBSD.org>
Cc:        "src-committers@freebsd.org" <src-committers@FreeBSD.org>, "dev-commits-src-all@freebsd.org" <dev-commits-src-all@FreeBSD.org>, "dev-commits-src-main@freebsd.org" <dev-commits-src-main@FreeBSD.org>
Subject:   Re: git: accfb4cc9346 - main - genoffset.sh: stop using a temporary file
Message-ID:  <39921E4A-4C15-4D8F-BA9F-D0C53AD62CD1@freebsd.org>
In-Reply-To: <202311161507.3AGF7kgx070201@gitrepo.freebsd.org>
References:  <202311161507.3AGF7kgx070201@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 16 Nov 2023, at 15:07, Jonathan T. Looney <jtl@FreeBSD.org> wrote:
>=20
> The branch main has been updated by jtl:
>=20
> URL: =
https://cgit.FreeBSD.org/src/commit/?id=3Daccfb4cc9346b23f6d6383dfc98d2c97=
ae18ce0d
>=20
> commit accfb4cc9346b23f6d6383dfc98d2c97ae18ce0d
> Author:     Jonathan T. Looney <jtl@FreeBSD.org>
> AuthorDate: 2023-11-16 15:02:32 +0000
> Commit:     Jonathan T. Looney <jtl@FreeBSD.org>
> CommitDate: 2023-11-16 15:02:32 +0000
>=20
>    genoffset.sh: stop using a temporary file
>=20
>    Instead, use a here document for the input. This allows us to run =
the
>    while loop in the main script so we can build the list of asserts =
in
>    a shell variable. We then print out the list of asserts at the end =
of
>    the loop.
>=20
>    Reviewed by:    imp
>    Sponsored by:   Netflix
>    Differential Revision:  https://reviews.freebsd.org/D42407
> ---
> sys/kern/genoffset.sh | 15 +++++++--------
> 1 file changed, 7 insertions(+), 8 deletions(-)
>=20
> diff --git a/sys/kern/genoffset.sh b/sys/kern/genoffset.sh
> index fda27998ca79..c974a7d52e8c 100644
> --- a/sys/kern/genoffset.sh
> +++ b/sys/kern/genoffset.sh
> @@ -35,16 +35,13 @@ usage()
>=20
> work()
> (
> -    local last off x1 x2 x3 struct field type lastoff lasttype
> +    local last off x1 x2 x3 struct field type lastoff lasttype =
asserts
>=20
>     echo "#ifndef _OFFSET_INC_"
>     echo "#define _OFFSET_INC_"
>     echo "#if !defined(GENOFFSET) && (!defined(KLD_MODULE) || =
defined(KLD_TIED))"
>     last=3D
> -    temp=3D$(mktemp -d genoffset.XXXXXXXXXX)
> -    trap "rm -rf ${temp}" EXIT
> -    # Note: we need to print symbol values in decimal so the numeric =
sort works
> -    ${NM:=3D'nm'} ${NMFLAGS} -t d "$1" | grep __assym_offset__ | sed =
-e 's/__/ /g' | sort -k 4 -k 1 -n |
> +    asserts=3D
>     while read off x1 x2 struct field type x3; do
> off=3D$(echo "$off" | sed -E 's/^0+//')
> if [ "$last" !=3D "$struct" ]; then
> @@ -60,12 +57,14 @@ work()
> printf "%b" "\t${type}\t${field};\n"
> lastoff=3D"$off"
> lasttype=3D"$type"
> - echo "_SA(${struct}, ${field}, ${off});" >> "$temp/asserts"
> -    done
> + asserts=3D"${asserts}_SA(${struct}, ${field}, ${off});\n"
> +    done <<EOT
> +$(${NM:=3D'nm'} ${NMFLAGS} -t d "$1" | grep __assym_offset__ | sed -e =
's/__/ /g' | sort -k 4 -k 1 -n)
> +EOT
>     echo "};"
>     echo "#define _SA(s,f,o) _Static_assert(__builtin_offsetof(struct =
s ## _lite, f) =3D=3D o, \\"
>     printf '\t"struct "#s"_lite field "#f" not at offset "#o)\n'
> -    cat "$temp/asserts"
> +    echo -e "${asserts}\c"

This isn=E2=80=99t POSIX, and isn=E2=80=99t supported by macOS=E2=80=99s =
sh, so breaks the
build there. Please fix or revert promptly.

Jess

>     echo "#undef _SA"
>     echo "#endif"
>     echo "#endif"




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?39921E4A-4C15-4D8F-BA9F-D0C53AD62CD1>