Linux-GPIO Archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Kent Gibson <warthog618@gmail.com>,
	Erik Schilling <erik.schilling@linaro.org>,
	Phil Howard <phil@gadgetoid.com>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	linux-gpio@vger.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [libgpiod][RFC/RFT 06/18] bindings: glib: add examples
Date: Tue, 23 Apr 2024 21:23:36 +0300	[thread overview]
Message-ID: <Zif8qBoZq7I3Xrbb@smile.fi.intel.com> (raw)
In-Reply-To: <20240412122804.109323-7-brgl@bgdev.pl>

On Fri, Apr 12, 2024 at 02:27:52PM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> Add example programs showcasing the usage of GLib bindings to libgpiod.

> +		ret = g_gpiod_chip_get_line_offset_from_name(chip, line_name,
> +							     &offset, &err);
> +		if (ret) {
> +			info = g_gpiod_chip_get_info(chip, &err);
> +			if (!info) {
> +				g_printerr("Failed to get chip info: %s\n",
> +					   err->message);
> +				return EXIT_FAILURE;
> +			}
> +
> +			g_print("%s %u\n",
> +				g_gpiod_chip_info_get_name(info),
> +				offset);
> +
> +			return EXIT_SUCCESS;
> +		} else if (!ret && err) {

Besides redundant 'else' the !ret is also redundant.

> +			g_printerr("Failed to map the line name '%s' to offset: %s\n",
> +				   line_name, err->message);
> +			return EXIT_FAILURE;
> +		}
> +	}

...

> +		direction == G_GPIOD_LINE_DIRECTION_INPUT ?
> +					"input" : "output",

One line?

...

> +	settings = g_gpiod_line_settings_new(
> +			"direction", G_GPIOD_LINE_DIRECTION_INPUT,
> +			NULL);

Personally I do not like the open parenthesis style...

I don't even know why you have done this way with having a plenty of room in
the previous line at least for the first parameter.

...

> +	req_cfg = g_gpiod_request_config_new(
> +			"consumer", "get-multiple-line-values", NULL);

Ditto. And so on across the code of the entire series...

...

> +	ret = g_gpiod_line_request_set_value(data->request, data->line_offset,
> +					     data->value, &err);
> +	if (!ret) {

ret == 0 equals error?!

> +		g_printerr("failed to set line value: %s\n", err->message);
> +		exit(EXIT_FAILURE);

Don't you have something like err->code to propagate?

> +	}


-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2024-04-23 18:23 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-12 12:27 [libgpiod][RFC/RFT 00/18] dbus: add GLib-based DBus daemon and command-line client Bartosz Golaszewski
2024-04-12 12:27 ` [libgpiod][RFC/RFT 01/18] tests: split out reusable test code into a local static library Bartosz Golaszewski
2024-04-12 12:27 ` [libgpiod][RFC/RFT 02/18] tests: split out the common test code for bash scripts Bartosz Golaszewski
2024-04-23 18:17   ` Andy Shevchenko
2024-04-12 12:27 ` [libgpiod][RFC/RFT 03/18] bindings: glib: add build files Bartosz Golaszewski
2024-04-12 12:27 ` [libgpiod][RFC/RFT 04/18] bindings: glib: add public headers Bartosz Golaszewski
2024-04-12 12:27 ` [libgpiod][RFC/RFT 05/18] bindings: glib: add core code Bartosz Golaszewski
2024-04-12 12:27 ` [libgpiod][RFC/RFT 06/18] bindings: glib: add examples Bartosz Golaszewski
2024-04-23 18:23   ` Andy Shevchenko [this message]
2024-04-12 12:27 ` [libgpiod][RFC/RFT 07/18] bindings: glib: add tests Bartosz Golaszewski
2024-04-12 12:27 ` [libgpiod][RFC/RFT 08/18] README: document GLib bindings Bartosz Golaszewski
2024-04-12 12:27 ` [libgpiod][RFC/RFT 09/18] dbus: add build files Bartosz Golaszewski
2024-04-12 12:27 ` [libgpiod][RFC/RFT 10/18] dbus: add the API definitions Bartosz Golaszewski
2024-04-12 12:27 ` [libgpiod][RFC/RFT 11/18] dbus: add a wrapper around the gdbus-codegen generated header Bartosz Golaszewski
2024-04-12 12:27 ` [libgpiod][RFC/RFT 12/18] dbus: add data files Bartosz Golaszewski
2024-04-12 12:27 ` [libgpiod][RFC/RFT 13/18] dbus: add gpio-manager code Bartosz Golaszewski
2024-04-12 12:28 ` [libgpiod][RFC/RFT 14/18] dbus: add tests Bartosz Golaszewski
2024-04-12 12:28 ` [libgpiod][RFC/RFT 15/18] dbus: add a command-line client Bartosz Golaszewski
2024-04-12 12:28 ` [libgpiod][RFC/RFT 16/18] dbus: client: add tests Bartosz Golaszewski
2024-04-12 12:28 ` [libgpiod][RFC/RFT 17/18] README: document the DBus API Bartosz Golaszewski
2024-04-12 12:28 ` [libgpiod][RFC/RFT 18/18] TODO: drop the DBus daemon from the list Bartosz Golaszewski
2024-04-23 17:41 ` [libgpiod][RFC/RFT 00/18] dbus: add GLib-based DBus daemon and command-line client Andy Shevchenko
2024-04-23 17:44   ` Bartosz Golaszewski

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zif8qBoZq7I3Xrbb@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=erik.schilling@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=phil@gadgetoid.com \
    --cc=viresh.kumar@linaro.org \
    --cc=warthog618@gmail.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.
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).