all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Peter Dyballa <Peter_Dyballa@Freenet.DE>, emacs-devel@gnu.org
Subject: Re: 23.0.50; dbus
Date: Wed, 02 Jan 2008 06:10:00 +0100	[thread overview]
Message-ID: <87tzlwyfrr.fsf@gmx.de> (raw)
In-Reply-To: <jwvlk799bgg.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Tue, 01 Jan 2008 22:06:07 -0500")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> 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))

Not really. NILP (uname) is explicitely one condition for the "then"
branch, that's intended. A robust check would be

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

I'm relatively sure that, if uname is non-nil, it must be a
string. However, an additional check wouldn't hurt.

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

Yes. But I still don't know what to do in the MacOS case, where tons of
compiler warnings are raised due to the signedness of the SDATA return
value. Peter has shown it in a recent message. Shall we always cast the
type like "strlen ((char *) SDATA (uname))"? This would affect much more
files but dbusbind.c.

>         Stefan

Best regards, Michael.

  reply	other threads:[~2008-01-02  5:10 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-10 12:00 23.0.50; dbus Peter Dyballa
2007-12-10 12:24 ` William Xu
2007-12-10 12:47   ` Jason Rumney
2007-12-10 12:56     ` Jason Rumney
2007-12-14 21:58 ` Michael Albinus
2007-12-15 10:41   ` Peter Dyballa
2007-12-16 22:57     ` Michael Albinus
2007-12-17 11:04       ` Peter Dyballa
2007-12-17 11:38         ` Michael Albinus
2007-12-21  0:05         ` Stefan Monnier
2007-12-21 19:49           ` Richard Stallman
2007-12-23 16:10       ` Peter Dyballa
2007-12-31 21:43         ` Michael Albinus
2007-12-31 22:26           ` Andreas Schwab
2008-01-01 10:46             ` Michael Albinus
2008-01-01 11:28               ` Peter Dyballa
2008-01-02  3:06           ` Stefan Monnier
2008-01-02  5:10             ` Michael Albinus [this message]
2008-01-02 11:40               ` Thien-Thi Nguyen
2008-01-02 12:48                 ` Michael Albinus
2008-01-02 13:41                   ` Thien-Thi Nguyen
2008-01-02 15:01               ` Stefan Monnier
2008-01-02 23:32                 ` Michael Albinus
2008-01-02 23:59                   ` Peter Dyballa
2008-01-03 12:28                   ` Jan Djärv
2008-01-05 15:25                     ` Peter Dyballa
2007-12-24 12:43       ` Peter Dyballa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tzlwyfrr.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=Peter_Dyballa@Freenet.DE \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.