[Top][All Lists]

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

Re: Type-error in C code

From: Jan Djärv
Subject: Re: Type-error in C code
Date: Fri, 12 Nov 2010 16:12:17 +0100
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; sv-SE; rv: Gecko/20101004 Thunderbird/3.1.5

An Atom is 32 bits. make_number can't cover that range when long is 32 bits, so it is an unsafe thing to do. Best is to revert and go back to using a string.

        Jan D.

Julien Danjou skrev 2010-11-12 15.21:
On Fri, Nov 12 2010, Stefan Monnier wrote:

static void
set_wm_state (Lisp_Object frame, int add, Atom atom, Atom value)
   struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (frame));

   x_send_client_event (frame, make_number (0), frame,
                        make_number (32),
                        /* 1 = add, 0 = remove */
                        (make_number (add ? 1 : 0),
                          value != 0 ? value : Qnil)));

The error is to put an "Atom" into a cons cell: those can only hold
Lisp_Objects.  The usual compilation flags won't catch the error because
both types are actually some kind of integer, but if you
compile --enable-use-lisp-union-type, the C compiler will
dutyfully burp.

Good catch Stefan. I should use this flag to compile my code now.

The fix should be easy I think, you just need to replace atom with
make_number (atom).

I can provide a patch is that handier.

reply via email to

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