[Top][All Lists]

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

Re: 23.0.50; dbus

From: Stefan Monnier
Subject: Re: 23.0.50; dbus
Date: Tue, 01 Jan 2008 22:06:07 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux)

> Here I'm lost. I use something like

>   if (NILP (uname) || (strlen (SDATA (uname)) > 0))

> uname is a Lisp_Object. SDATA (uname) returns (char *). What kind of
> signedness do I break in strlen? Does anybody have an idea?

Someone else already answered the question, but I'll just take the
opportunity to point out that the above code is a common small bug:
the strlen may crash if uname is neither nil nor a string.
A better way to write such code is

   if (STRINGP (uname) && (strlen (SDATA (uname)) > 0))

Another benefit is that the compiler can do a better job of
eliminating the (now) redundant STRINGP test that may lurk
inside SDATA.


reply via email to

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