Code Block Purpose?

Doug Goldstein cardoe at gentoo.org
Fri May 18 08:17:01 PDT 2007


Danny Kukawka wrote:
> On Freitag, 18. Mai 2007, Doug Goldstein wrote:
> [..]
>   
>> Looking at the code.... ci-tracker.c lines 197 to 203:
>>
>>         dbus_error_init (&error);
>>         ci->uid = dbus_bus_get_unix_user (cit->dbus_connection,
>> system_bus_unique_name, &error);
>>         if (ci->uid == ((unsigned long) -1) || dbus_error_is_set (&error))
>> { HAL_WARNING (("Could not get uid for connection: %s %s", error.name,
>> error.message));
>>                 dbus_error_free (&error);
>>                 goto error;
>>         }
>>
>> We see that dbus_bus_get_unix_user() is failing. The check below that on
>> line 199 is invalid since dbus_bus_get_unix_user() returns an unsigned
>> long so the casting of -1 to an unsigned long, which in a perfect world
>> would be LONG_MAX will differ on amd64 machines and x86 machines which
>> means that check will always be bad. Further more, D-Bus returns
>> DBUS_UID_UNSET on failure. 
>>     
>
> and DBUS_UID_UNSET is: ((dbus_uid_t) -1) while dbus_uid_t is unsigned long. 
> Hence 'ci->uid == ((unsigned long) -1)' looks valid to me.
>
> Danny
> _______________________________________________
> hal mailing list
> hal at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/hal
>
>   
Does not address the fact that if we check for that result and then
print out an error. We're assuming that D-Bus populated the error
structure, which it possibly did not. So that check is still flawed.

But that's just a small side item in the bigger picture of my original
e-mail.


More information about the hal mailing list