Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 May 2005 23:49:29 -0700
From:      John-Mark Gurney <gurney_j@resnet.uoregon.edu>
To:        Colin Percival <cperciva@freebsd.org>
Cc:        freebsd-arch@freebsd.org
Subject:   Re: RFC: Using fixed-length strings for version[] and osrelease[]
Message-ID:  <20050520064929.GC959@funkthat.com>
In-Reply-To: <428D26C1.2020201@freebsd.org>
References:  <428D26C1.2020201@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Colin Percival wrote this message on Thu, May 19, 2005 at 16:52 -0700:
> Would anyone object to the following patch being applied?
> 
> --- newvers.sh  15 Jan 2005 13:25:41 -0000      1.68
> +++ newvers.sh  19 May 2005 23:48:21 -0000
> @@ -87,9 +87,9 @@ cat << EOF > vers.c
>  $COPYRIGHT
>  char sccspad[32 - 4 /* sizeof(sccs) */] = { '\\0' };
>  char sccs[4] = { '@', '(', '#', ')' };
> -char version[] = "${VERSION} #${v}: ${t}\\n    ${u}@${h}:${d}\\n";
> +char version[512] = "${VERSION} #${v}: ${t}\\n    ${u}@${h}:${d}\\n";
>  char ostype[] = "${TYPE}";
> -char osrelease[] = "${RELEASE}";
> +char osrelease[64] = "${RELEASE}";
>  int osreldate = ${RELDATE};
>  char kern_ident[] = "${i}";
>  EOF
> 
> The lengths 512 and 64 are chosen as being considerably more than double the
> likely lengths of these strings; on my system, these two strings are 12 bytes
> and 134 bytes long respectively.

Nope, but I would say make them just a bit larger than necessary right
now, and add the necessary CTASSERT lines to make sure we don't overflow..

I'd say no more than 256 bytes for the VERSION string, since CTASSERT will
prevent the overflow...

Though you might want to make the fixed size dependent upon the release
kernel and not for custom compiled kernels...  No point in penalizing
kernels that don't need this...

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050520064929.GC959>