[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#43252: 27.1; DBus properties lack type hints or overrides
From: |
Michael Albinus |
Subject: |
bug#43252: 27.1; DBus properties lack type hints or overrides |
Date: |
Sun, 20 Sep 2020 17:05:47 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Hugh Daschbach <hugh@ccss.com> writes:
Hi Hugh,
>>> +
>>> + (should ; Should this error
>>> instead?
>>> + (equal
>>> + (dbus-set-property
>>> ...
>>> + '(:array "seven" "eight" :string "nine"))
>>
>> Good question. dbus-set-property and dbus-get-property do not
>> propagate
>> D-Bus errors. Maybe we shall change the functions to do so? I've
>> asked
>> this already myself.
>
> I don't have a strong opinion either way. I'm just trying to note
> corner cases.
Well, I have adapted dbus-set-property and dbus-get-property to
propagate the errors.
>>> + ;; Test mismatched types in array
>>> +
>>> + (should ; Oddly enough, register
>>> works, but get fails
>>> + (equal
>>
>> Hmm, yes. dbus-register-property does not perform a local type
>> check. And honestly, I don't want to do it; I let the D-Bus daemon
>> do
>> the job.
>
> Great.
Should be checked now. When dbus-register-property is called, it applies
internally a dbus-set-property or dbus-get-property now. As side effect,
the value is checked by the D-Bus daemon, and you shall see errors.
>> And even if you would have prefixed the value with :byte, there
>> won't be
>> an error. In dbusbind.c, byte values are simply computed by taking
>> the
>> modulo 255:
>>
>> unsigned char val = XFIXNAT (object) & 0xFF;
>>
>> ":byte 1024" is equal to ":byte 4". Similar conversions happen for
>> the
>> other basic types, based on numbers.
>
> Good. I haven't thought deeply enough about DBus to anticipate
> truncation. I've added a test for this, an extract of which is below.
> The get returns nil instead of 4. I can change the expected value,
> but
> wanted to run this by you first.
Of course I'm wrong, ":byte 1024" shall be the same as "byte 0".
> (ert-deftest dbus-test-ad-hoc ()
> (dbus-ignore-errors (dbus-unregister-service :session
> dbus--test-service))
> (dbus-register-service :session dbus--test-service)
> (should ; Test value truncation
> (equal
> (dbus-register-property
> :session dbus--test-service dbus--test-path
> dbus--test-interface "ByteValue" :read :byte 1024)
> `((:property :session ,dbus--test-interface "ByteValue")
> (,dbus--test-service ,dbus--test-path))))
>
> (should ; Returns 0 instead of 4.
> (equal
> (dbus-get-property
> :session dbus--test-service dbus--test-path
> dbus--test-interface "ByteValue")
> 4))
Of course 0. As said, I was wrong.
> (dbus-unregister-service :session dbus--test-service))
>
> Should I update the expectation to zero?
Yes, please.
> Cheers,
> Hugh
Best regards, Michael.
- bug#43252: 27.1; DBus properties lack type hints or overrides, (continued)
- bug#43252: 27.1; DBus properties lack type hints or overrides, Michael Albinus, 2020/09/16
- bug#43252: 27.1; DBus properties lack type hints or overrides, Hugh Daschbach, 2020/09/16
- bug#43252: 27.1; DBus properties lack type hints or overrides, Michael Albinus, 2020/09/17
- bug#43252: 27.1; DBus properties lack type hints or overrides, Hugh Daschbach, 2020/09/17
- bug#43252: 27.1; DBus properties lack type hints or overrides, Hugh Daschbach, 2020/09/18
- bug#43252: 27.1; DBus properties lack type hints or overrides, Michael Albinus, 2020/09/18
- bug#43252: 27.1; DBus properties lack type hints or overrides, Michael Albinus, 2020/09/18
- bug#43252: 27.1; DBus properties lack type hints or overrides, Michael Albinus, 2020/09/18
- bug#43252: 27.1; DBus properties lack type hints or overrides, Michael Albinus, 2020/09/18
- bug#43252: 27.1; DBus properties lack type hints or overrides, Hugh Daschbach, 2020/09/18
- bug#43252: 27.1; DBus properties lack type hints or overrides,
Michael Albinus <=
- bug#43252: 27.1; DBus properties lack type hints or overrides, Michael Albinus, 2020/09/21
- bug#43252: 27.1; DBus properties lack type hints or overrides, Hugh Daschbach, 2020/09/21
- bug#43252: 27.1; DBus properties lack type hints or overrides, Michael Albinus, 2020/09/22
- bug#43252: 27.1; DBus properties lack type hints or overrides, Michael Albinus, 2020/09/22
- bug#43252: 27.1; DBus properties lack type hints or overrides, Hugh Daschbach, 2020/09/22
- bug#43252: 27.1; DBus properties lack type hints or overrides, Hugh Daschbach, 2020/09/22
- bug#43252: 27.1; DBus properties lack type hints or overrides, Michael Albinus, 2020/09/23
- bug#43252: 27.1; DBus properties lack type hints or overrides, Michael Albinus, 2020/09/23
- bug#43252: 27.1; DBus properties lack type hints or overrides, Hugh Daschbach, 2020/09/23
- bug#43252: 27.1; DBus properties lack type hints or overrides, Michael Albinus, 2020/09/24