From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F024EC43462 for ; Fri, 16 Apr 2021 14:58:44 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6F04261166 for ; Fri, 16 Apr 2021 14:58:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F04261166 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=stwcx.xyz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4FMK8z088mz3bqg for ; Sat, 17 Apr 2021 00:58:43 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=stwcx.xyz header.i=@stwcx.xyz header.a=rsa-sha256 header.s=fm1 header.b=y4iEw+0r; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=Cs3CMZ3/; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=stwcx.xyz (client-ip=66.111.4.27; helo=out3-smtp.messagingengine.com; envelope-from=patrick@stwcx.xyz; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=stwcx.xyz header.i=@stwcx.xyz header.a=rsa-sha256 header.s=fm1 header.b=y4iEw+0r; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=Cs3CMZ3/; dkim-atps=neutral Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4FMK8K5cZMz3bvK for ; Sat, 17 Apr 2021 00:58:08 +1000 (AEST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 3F3705C00AF; Fri, 16 Apr 2021 10:58:05 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 16 Apr 2021 10:58:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stwcx.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=5AnvCyoyptU5x5NtdQcpBAJXihE 0B2I0/0hzmrnD/M0=; b=y4iEw+0rOD/x8gL1A3A6xDBONafYFdw7GFQv9w0921J +2tLHJdsUjeXJZrfF8n0YtAnLxNkQAbTmCePEInoTRoa3CyWLf7c8C4WBito29Rq aKv/l2heVnxwQG15jIadK0eCc5vqLN4tFeI3Mukys2OSYl82OCFVOa7mulqhMHGC Y1PWvzeCvJcmPfUA1PME0/vnZfWMOd39TeXhQS1rP4O/7/abd8QcRIvbbJo1yUvo epGXqZsRyGyyT4krxp8MCgvBET0ZhN2Il4nDVjRYawd6FXbdG3iC4ocdY86QNhaM bX0neiX4yf70/396/pmgc53qXitLVj/aEb4ZOivrzJg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=5AnvCy oyptU5x5NtdQcpBAJXihE0B2I0/0hzmrnD/M0=; b=Cs3CMZ3/onGctWPW1A0Tkn utp7WTHtF6k9SS5Yu6GSBm69QyOWq1dFt8nTuYph2zb3yQx20yul0bMxzblJ8o8+ /FiWYwDxDZIb/CKmck/IxMq8GhbiiEcY8p3NWAuhIxEzn+AOQpNee6GCxv7V1J66 6QfZJqfsKkdHBiR3QQzssrt3pXmaazWZhocMPT/XWLoAc9W9vDGMMAVB/1aT+sE5 hnPLXI5P6SMIRi06B68GN9dL05FgSwoxsm3NwRK2/xHUIDXVJPT3sHVxf83/NhLm C0c0P5pmscIBIjXheZD4KGPpsQwxTWgLLnmwvxw53eOoCfqSXVkpIT1sr84tZ5zA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudelhedgkeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvuffkfhggtggujgesghdtreertddt jeenucfhrhhomheprfgrthhrihgtkhcuhghilhhlihgrmhhsuceophgrthhrihgtkhessh htfigtgidrgiihiieqnecuggftrfgrthhtvghrnhepkeduuedtfeeihfehfeehfedvjeeu jeeikedtteehledvhfelheekgedvieevkefhnecukfhppedutdejrdelvddrheelrddvud ejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphgr thhrihgtkhesshhtfigtgidrgiihii X-ME-Proxy: Received: from localhost (mobile-107-92-59-217.mycingular.net [107.92.59.217]) by mail.messagingengine.com (Postfix) with ESMTPA id 6D8AE1080057; Fri, 16 Apr 2021 10:58:04 -0400 (EDT) Date: Fri, 16 Apr 2021 09:58:03 -0500 From: Patrick Williams To: Bruce Lee =?utf-8?B?KOadjuaYgOWzuyk=?= Subject: Re: How to get the return value using the command busctl set-property? Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="cBG35bXSpcBvGbf2" Content-Disposition: inline In-Reply-To: X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "openbmc@lists.ozlabs.org" , "edtanous@google.com" , Nan Zhou Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org Sender: "openbmc" --cBG35bXSpcBvGbf2 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Apr 16, 2021 at 04:46:00AM +0000, Bruce Lee (=E6=9D=8E=E6=98=80=E5= =B3=BB) wrote: > Does busctl set-property can get its return value? =2E.. > If can get its return value from set-property, how to do it? There isn't really a return value from a set-property call; there is only a possiblity of error. If you look at 'man SD_BUS_PROPERTY' you'll see the function type for a property set is: typedef int (*sd_bus_property_set_t)(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *value, void *userdata, sd_bus_error *ret_error); This is where the 'int' return you're seeing from these set-property handlers coming from. The way systemd handles the return code is that any negative number becomes a negative errno style value that systemd turns into an appropriate error message back across the dbus. There is a paragraph in the manpage with more details: If a callback was invoked to handle a request that expects a reply a= nd the callback returns a negative value, the value is interpreted as a negative errno-style error code and sent back to the caller as a D-B= us error as if sd_bus_reply_method_errno(3) was called. Additionally, a= ll callbacks take a sd_bus_error output parameter that can be used to provide more detailed error information. If ret_error is set when the callback finishes, the corresponding D-Bus error is sent back to the caller as if sd_bus_reply_method_error(3) was called. Any error stor= ed in ret_error takes priority over any negative values returned by the same callback when determining which error to send back to the calle= r. The *best* way for a set-property handler to return an error is to use the sd_bus_reply_method_error or fill out the ret_error with sd_bus_error_set. Both the ASIO object_server.hpp and the sdbus++-generated server bindings catch excpetions thrown out of the set-property handlers and turn them into sd_bus_error_set calls. Other than the negative value indicating a errno, the positive value has no meaning and does not do anything at a dbus level. --=20 Patrick Williams --cBG35bXSpcBvGbf2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEBGD9ii4LE9cNbqJBqwNHzC0AwRkFAmB5pfkACgkQqwNHzC0A wRnbzA//V9OJbOORjX5tOC3aILv0KpQVwdaqRzRLG1rbpfCLHm9i1BK9uDeyOxSR TzM6iFCaeY/AQOUtqEmkb+a16mh2QWcJ/HC+6pregR6Em2jYkbb/YALb7Wvv/cnT YKm3X3ICq2spVLxJb+bgDeN98dfNSvug9EJefSTT8kbz20SOmGrLzT7wPanz8uDv Rjs+J9FkiNvAR1/TF8r1asAI2bbqQ99Ozdsa6iKpqyxVBKsqw8ttNT9Ik/NBXzZp Zr8sSbiKOU21s1nmOtH/TgxlBW3fKbLPo5LJHUTCp8zk5Lpwns4+IeZ2zn9U+SZA y7pHC1lKr1Ks8j/MsoV27lon5ioIGcVcVjo2OFHhG0V9C3g5AIqKe42nOQMV8a1u jZx3BjDkG0kOC+wHJWIQR+KVpg6OX2MloRSqZ9U1aAwPdm6mFQ3XaD8V0lQsNJL7 kd+QyI7ug8aVdTp/U6n+/JuP/1/flNl1tMzl2pynTp+V7Gpl0g2pvzedtV8HmkXx ieiilKo8av3w0FxPFB1hS+twmiEQgem0ufajQSvmXV6w247zErMuiQ54VJutFok4 /sBTmo2EomcRW05mVMC9QqV1w6+qVYnqti9u8n/0y1GdOb1AMoVv4EGm3Bvra574 F/T9uUoM9P8Uyx0E9D3gteMq+K+AWtVvz7urnCWPadAfRPMLOf8= =9LPH -----END PGP SIGNATURE----- --cBG35bXSpcBvGbf2--