qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-trivial] [Qemu-devel] [PATCH for-2.10] Use qemu_tolower() and


From: Richard Henderson
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH for-2.10] Use qemu_tolower() and qemu_toupper(), not tolower() and toupper()
Date: Thu, 20 Jul 2017 08:57:30 -1000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

On 07/20/2017 08:48 AM, Eric Blake wrote:
On 07/20/2017 01:26 PM, Richard Henderson wrote:
On 07/20/2017 06:31 AM, Peter Maydell wrote:
gdbstub.c:914:13: warning: array subscript has type 'char'

This reflects the fact that toupper() and tolower() give
undefined behaviour if they are passed a value that isn't
a valid 'unsigned char' or EOF.

Not saying we shouldn't use qemu_tolower etc, but this statement is not
true at all.  Officially, the argument to toupper and tolower is type int.

Correct. Officially, the argument to toupper is an int, but
range-constrained to the set of ints that represent either EOF or an
unsigned char value.

Please show me that language in C11 (or any other version).
My copy has:

   7.4.2.2 The toupper function

   Synopsis
1  #include <ctype.h>
   int toupper(int c);

   Description
2  The toupper function converts a lowercase letter to a corresponding
   uppercase letter.

   Returns
3  If the argument is a character for which islower is true and there
   are one or more corresponding characters, as specified by the current
   locale, for which isupper is true, the toupper function returns one
   of the corresponding characters (always the same one for any given
   locale); otherwise, the argument is returned unchanged.

I see nothing about range constraints.  The word "unsigned" does not appear.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]