[PATCH] os: Print a newline when Error is called

Alan Coopersmith alan.coopersmith at oracle.com
Mon Oct 10 19:14:51 PDT 2011


On 10/10/11 06:24 PM, Peter Hutterer wrote:
> On Mon, Oct 10, 2011 at 05:53:07PM -0700, Jeremy Huddleston wrote:
>> --- a/os/log.c
>> +++ b/os/log.c
>> @@ -646,9 +646,9 @@ Error(const char *str)
>>       const char *err = strerror(errno);
>>
>>       if (str)
>> -	LogWrite(-1, "%s: %s", str, err);
>> +	LogWrite(-1, "%s: %s\n", str, err);
>>       else
>> -	LogWrite(-1, "%s", err);
>> +	LogWrite(-1, "%s\n", err);
>>   }
>>
>>   void
>> --
>> 1.7.5.4
>
> There are only very few callers. IMO we should replace them with
>      ErrorF("%s", strerror(errno));
> and remove this one completely.

Do any platforms we support ever return a NULL from strerror() as
the above checks for?

Solaris man pages seem to guarantee a non-NULL return ("Unknown error"
is returned for an unrecognized errno), and neither the C89 nor SUSv2
spec mention NULL ever being returned, even noting there is no return
value that can indicate an error happened.   The latest Unix spec is
even clearer:

     ...strerror() shall map any value of type int to a message.

     Upon completion, whether successful or not, strerror() shall
     return a pointer to the generated message string.

-- 
	-Alan Coopersmith-        alan.coopersmith at oracle.com
	 Oracle Solaris Platform Engineering: X Window System



More information about the xorg-devel mailing list