From: Guenter Roeck <linux@roeck-us.net>
To: "Peter Hüwe" <PeterHuewe@gmx.de>
Cc: linux-hwmon@vger.kernel.org, Jean Delvare <jdelvare@suse.com>,
linux-kernel@vger.kernel.org
Subject: Re: Question about hwmon_attr_show_string
Date: Mon, 6 Mar 2017 15:47:55 -0800 [thread overview]
Message-ID: <20170306234755.GA16512@roeck-us.net> (raw)
In-Reply-To: <201703062148.36101.PeterHuewe@gmx.de>
On Mon, Mar 06, 2017 at 09:48:35PM +0100, Peter Hüwe wrote:
> Hi Guenter,
>
> I was wondering whether there was a particular reason why
> hwmon_attr_show_string passes only an "empty" pointer(pointer) to the ops-
> >read_string function rather than the buffer itself?
>
> Wouldn't this mean that in ops->read_string I'd have to reserve some space for
> the value on the heap (and taking care to free it somewhere, since returning
> an address on the stack is bad idea), instead of calling sprintf(buf, "%s\n",
> s) directly?
>
> With the current implementation I have to sprintf it into my local buffer and
> you sprintf it again into the final buffer.
>
The idea was that the called code would return a pointer to a constant string,
ie one that isn't changing from call to call.
What attribute do you see that would require a dynamic (changing) string ?
Thanks,
Guenter
next prev parent reply other threads:[~2017-03-07 2:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-03 0:33 Conversion of w83627ehf to hwmon_device_register_with_info ? Peter Hüwe
2017-03-03 2:56 ` Guenter Roeck
2017-03-21 10:46 ` Peter Hüwe
2017-03-21 13:35 ` Guenter Roeck
2017-03-23 1:11 ` Peter Hüwe
2017-03-03 10:52 ` Jean Delvare
2017-03-06 20:48 ` Question about hwmon_attr_show_string Peter Hüwe
2017-03-06 23:47 ` Guenter Roeck [this message]
2017-03-07 9:08 ` Jean Delvare
2017-03-07 9:14 ` Peter Huewe
2017-03-07 14:16 ` Guenter Roeck
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=20170306234755.GA16512@roeck-us.net \
--to=linux@roeck-us.net \
--cc=PeterHuewe@gmx.de \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox