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