[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 5/5] uname: Put platform-dependent checks one after another.
From: |
Bruno Haible |
Subject: |
Re: [PATCH 5/5] uname: Put platform-dependent checks one after another. |
Date: |
Fri, 2 Oct 2009 02:31:49 +0200 |
User-agent: |
KMail/1.9.9 |
Paolo Bonzini wrote:
> I move computation of sysname towards
> the end of the function, so that the compiler can thread from one
> if to the following switch
The order of the blocks in the code was determined by the order in
the struct in sys/utsname.h:
/* Name of this node on the network. */
char nodename[_UTSNAME_NODENAME_LENGTH];
/* Name of the implementation of the operating system. */
char sysname[_UTSNAME_SYSNAME_LENGTH];
/* Current release level of this implementation. */
char release[_UTSNAME_RELEASE_LENGTH];
/* Current version level of this release. */
char version[_UTSNAME_VERSION_LENGTH];
/* Name of the hardware type the system is running on. */
char machine[_UTSNAME_MACHINE_LENGTH];
If you follow that order, it is bullet proof sure that all
fields are filled. If you permute the order, you open up the
door for the next maintainer to write one field twice, or
to omit filling one of the fields. So, I object to this change,
for maintainability reasons.
> Also, in case this is being compiled with MSVC I do append the
> version number to the uname -m value.
What for? How is the user expected to understand what "Windows-6.1"
means?
> + sprintf (buf->sysname, "%s%s-%u.%u",
> +#ifdef __MINGW32__
> + "MINGW32_",
> +#else
> + "Windows",
> +#endif
> + super_version,
> + (unsigned int) version.dwMajorVersion,
> + (unsigned int) version.dwMinorVersion);
> +
This can lead to compilation failures: sprintf may be a macro, and
ANSI C forbids #ifs inside macro argument lists.
Bruno
- Re: multiple target patterns, Paolo Bonzini, 2009/10/01
- [PATCH 1/5] win32: Use ANSI functions, Paolo Bonzini, 2009/10/01
- [PATCH 2/5] uname: use only one OSVERSIONINFOEXA struct, use ANSI version, Paolo Bonzini, 2009/10/01
- Re: [PATCH 4/5] Handle Windows CE and rewrite NT version handling., Bruno Haible, 2009/10/01
- Re: [PATCH 4/5] Handle Windows CE and rewrite NT version handling., Paolo Bonzini, 2009/10/01
- Re: [PATCH 4/5] Handle Windows CE and rewrite NT version handling., Bruno Haible, 2009/10/01
- Re: [PATCH 4/5] Handle Windows CE and rewrite NT version handling., Paolo Bonzini, 2009/10/01
- Re: [PATCH 2/5] uname: use only one OSVERSIONINFOEXA struct, use ANSI version, Bruno Haible, 2009/10/01
- Re: [PATCH 2/5] uname: use only one OSVERSIONINFOEXA struct, use ANSI version, Bruno Haible, 2009/10/01
- Re: [PATCH 2/5] uname: use only one OSVERSIONINFOEXA struct, use ANSI version, Paolo Bonzini, 2009/10/01
Re: [PATCH 1/5] win32: Use ANSI functions, Jim Meyering, 2009/10/01
Re: [PATCH 1/5] win32: Use ANSI functions, Bruno Haible, 2009/10/01