From: Jean Delvare <khali@linux-fr.org>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH] libsensors: No longer depend on libsysfs
Date: Sun, 16 Dec 2007 19:25:26 +0000 [thread overview]
Message-ID: <20071216202526.0de03bce@hyperion.delvare> (raw)
In-Reply-To: <20071129120153.26879145@hyperion.delvare>
Hi Mark,
On Sun, 16 Dec 2007 13:59:02 -0500, Mark M. Hoffman wrote:
> Hi Jean:
>
> * Jean Delvare <khali@linux-fr.org> [2007-12-10 14:30:57 +0100]:
> > On Sun, 2 Dec 2007 21:42:39 +0100, Jean Delvare wrote:
> > > Well, I have no reason to believe that anything is wrong with this
> > > patch, as all my testing has been successful. Feel free to apply it to
> > > Rawhide if you want. I would like to commit the change soon, the only
> > > thing I am waiting for at the moment is Mark's ack, as we had been
> > > discussing the matter before, he might want to comment on the approach
> > > I took in my patch.
> >
> > Patch is committed now.
>
> I've finally finished reviewing this. I only have one minor change to
> suggest, which IMHO makes the code a little more readable at very little
> expense in cycles and no expense in size.
>
> Index: lib/sysfs.c
> =================================> --- lib/sysfs.c (revision 5072)
> +++ lib/sysfs.c (working copy)
> @@ -73,7 +73,7 @@
> * local errors, or a negative error value if any call fails.
> */
> static int sysfs_foreach_classdev(const char *class_name,
> - int (*func)(char *, const char*))
> + int (*func)(const char *, const char *))
> {
> char path[NAME_MAX];
> int path_off, ret;
> @@ -105,7 +105,7 @@
> * local errors, or a negative error value if any call fails.
> */
> static int sysfs_foreach_busdev(const char *bus_type,
> - int (*func)(char *, const char*))
> + int (*func)(const char *, const char *))
> {
> char path[NAME_MAX];
> int path_off, ret;
> @@ -455,7 +455,7 @@
> }
>
> /* returns: 0 if successful, !0 otherwise */
> -static int sensors_read_one_sysfs_chip(char *dev_path, const char *dev_name)
> +static int sensors_read_one_sysfs_chip(const char *dev_path, const char *dev_name)
> {
> int domain, bus, slot, fn;
> int err = -SENSORS_ERR_KERNEL;
> @@ -539,20 +539,20 @@
> return 0;
> }
>
> -static int sensors_add_hwmon_device(char *path, const char *classdev)
> +static int sensors_add_hwmon_device(const char *path, const char *classdev)
> {
> + char linkpath[NAME_MAX];
> char device[NAME_MAX];
> - int path_off = strlen(path);
> int dev_len;
> (void)classdev; /* hide warning */
>
> - snprintf(path + path_off, NAME_MAX - path_off, "/device");
> - dev_len = readlink(path, device, NAME_MAX - 1);
> + snprintf(linkpath, NAME_MAX, "%s/device", path);
> + dev_len = readlink(linkpath, device, NAME_MAX - 1);
> if (dev_len < 0)
> return -SENSORS_ERR_KERNEL;
> device[dev_len] = '\0';
>
> - return sensors_read_one_sysfs_chip(path, strrchr(device, '/') + 1);
> + return sensors_read_one_sysfs_chip(linkpath, strrchr(device, '/') + 1);
> }
>
> /* returns 0 if successful, !0 otherwise */
> @@ -572,7 +572,7 @@
> }
>
> /* returns 0 if successful, !0 otherwise */
> -static int sensors_add_i2c_bus(char *path, const char *classdev)
> +static int sensors_add_i2c_bus(const char *path, const char *classdev)
> {
> sensors_bus entry;
>
I'm totally fine with this patch, I agree that it's somewhat cleaner
and the additional cost is negligible. Feel free to apply it to SVN.
Thanks for the review,
--
Jean Delvare
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
next prev parent reply other threads:[~2007-12-16 19:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-29 11:01 [lm-sensors] [PATCH] libsensors: No longer depend on libsysfs Jean Delvare
2007-11-29 18:16 ` Hans de Goede
2007-11-29 18:52 ` Jean Delvare
2007-12-02 19:39 ` Hans de Goede
2007-12-02 20:42 ` Jean Delvare
2007-12-10 13:30 ` Jean Delvare
2007-12-16 18:59 ` Mark M. Hoffman
2007-12-16 19:25 ` Jean Delvare [this message]
2007-12-16 19:41 ` Mark M. Hoffman
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=20071216202526.0de03bce@hyperion.delvare \
--to=khali@linux-fr.org \
--cc=lm-sensors@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.