On Mon, Nov 16, 2015 at 11:31:32AM +0100, Pavel Březina wrote:
On 11/11/2015 02:28 PM, Jakub Hrozek wrote:
>Hi,
>
>I think one of the prime reasons for #2861 was copy-pasting code. The
>two attached patches reduce the code duplication and hopefully will make
>future additions to Data Provider safer.
>
>Ideas on different solutions are welcome!
>+static errno_t be_sbus_req_reply(struct sbus_request *sbus_req,
>+ const char *req_name,
>+ int dp_err_type,
>+ int errnum,
>+ const char *errstr)
>+{
>+ const char *req_msg;
>+ dbus_uint16_t err_maj;
>+ dbus_uint32_t err_min;
>+
>+ err_maj = dp_err_type;
>+ err_min = errnum;
>+
>+ req_msg = req_name ? req_name : "sbus";
^^ unused, along with req_name
Oops, now it is (I couldn't make my mind on how to report the caller,
feel free to suggest a better one)
>+ return be_sbus_reply(sbus_req, err_maj, err_min, errstr);
>+}
>+static inline void be_sbus_reply_data_set(struct be_sbus_reply_data *rdata,
>+ dbus_uint16_t err_maj,
>+ dbus_uint32_t err_min,
>+ const char *err_msg)
>+{
if (rdata == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, "Bug: ...\n");
Done.
}
>+ if (rdata) {
>+ rdata->err_maj = err_maj;
>+ rdata->err_min = err_min;
>+ rdata->err_msg = err_msg;
>+ }
>+}
I like it!
Thanks, new patches are attached.