From: Michael Albinus <michael.albinus@gmx.de>
To: Hugh Daschbach <hugh@ccss.com>
Cc: 43252@debbugs.gnu.org
Subject: bug#43252: 27.1; DBus properties lack type hints or overrides
Date: Sun, 20 Sep 2020 17:05:47 +0200 [thread overview]
Message-ID: <87ft7c8p4k.fsf@gmx.de> (raw)
In-Reply-To: <875z8aa1bm.fsf@ccss.com> (Hugh Daschbach's message of "Fri, 18 Sep 2020 20:32:29 -0700")
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.
next prev parent reply other threads:[~2020-09-20 15:05 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-07 0:54 bug#43252: 27.1; DBus properties lack type hints or overrides Hugh Daschbach
2020-09-07 7:48 ` Michael Albinus
2020-09-07 17:35 ` Hugh Daschbach
2020-09-07 18:00 ` Michael Albinus
2020-09-07 19:18 ` Hugh Daschbach
2020-09-08 14:36 ` Michael Albinus
2020-09-09 4:10 ` Hugh Daschbach
2020-09-09 4:25 ` Hugh Daschbach
2020-09-09 13:25 ` Michael Albinus
2020-09-09 16:12 ` Hugh Daschbach
2020-09-09 17:43 ` Michael Albinus
[not found] ` <874ko6979w.fsf@gmx.de>
[not found] ` <87v9gm9x9i.fsf@ccss.com>
2020-09-10 14:59 ` Michael Albinus
2020-09-10 16:57 ` Michael Albinus
2020-09-10 19:09 ` Hugh Daschbach
2020-09-11 8:46 ` Michael Albinus
2020-09-10 22:53 ` Hugh Daschbach
2020-09-11 9:57 ` Michael Albinus
2020-09-11 14:19 ` Michael Albinus
2020-09-15 4:05 ` Hugh Daschbach
2020-09-16 12:47 ` Michael Albinus
2020-09-16 22:23 ` Hugh Daschbach
2020-09-17 12:58 ` Michael Albinus
2020-09-17 18:42 ` Hugh Daschbach
2020-09-18 6:28 ` Hugh Daschbach
2020-09-18 9:55 ` Michael Albinus
2020-09-18 13:42 ` Michael Albinus
2020-09-18 15:50 ` Michael Albinus
2020-09-18 9:36 ` Michael Albinus
2020-09-19 3:32 ` Hugh Daschbach
2020-09-20 15:05 ` Michael Albinus [this message]
2020-09-21 11:50 ` Michael Albinus
2020-09-22 3:48 ` Hugh Daschbach
2020-09-22 16:09 ` Michael Albinus
2020-09-22 17:36 ` Michael Albinus
2020-09-23 3:30 ` Hugh Daschbach
2020-09-23 3:34 ` Hugh Daschbach
2020-09-23 7:44 ` Michael Albinus
2020-09-23 17:32 ` Michael Albinus
2020-09-24 3:02 ` Hugh Daschbach
2020-09-24 8:48 ` Michael Albinus
2020-09-25 4:16 ` Hugh Daschbach
2020-09-26 1:27 ` Hugh Daschbach
2020-09-26 9:51 ` Michael Albinus
2020-09-28 3:00 ` Hugh Daschbach
2020-09-28 12:55 ` Michael Albinus
2020-09-28 23:17 ` Hugh Daschbach
2020-09-29 12:22 ` Michael Albinus
2020-09-29 21:51 ` Hugh Daschbach
2020-09-30 9:34 ` Michael Albinus
2020-09-30 10:42 ` Michael Albinus
2020-09-30 16:39 ` Hugh Daschbach
2020-09-10 8:00 ` bug#43252: Fwd: " Michael Albinus
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ft7c8p4k.fsf@gmx.de \
--to=michael.albinus@gmx.de \
--cc=43252@debbugs.gnu.org \
--cc=hugh@ccss.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).