Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1593805
| From | Guenter Roeck <linux@roeck-us.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: Question about hwmon_attr_show_string |
| Date | 2017-03-07 01:00 +0100 |
| Message-ID | <tiaHL-7eE-3@gated-at.bofh.it> (permalink) |
| References | <tgJqh-1AZ-1@gated-at.bofh.it> <ti7JU-5av-21@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Conversion of w83627ehf to hwmon_device_register_with_info ? Peter Hüwe <PeterHuewe@gmx.de> - 2017-03-03 01:40 +0100
Re: Conversion of w83627ehf to hwmon_device_register_with_info ? Guenter Roeck <linux@roeck-us.net> - 2017-03-03 04:00 +0100
Re: Conversion of w83627ehf to hwmon_device_register_with_info ? Jean Delvare <jdelvare@suse.de> - 2017-03-03 16:10 +0100
Question about hwmon_attr_show_string Peter Hüwe <PeterHuewe@gmx.de> - 2017-03-06 21:50 +0100
Re: Question about hwmon_attr_show_string Guenter Roeck <linux@roeck-us.net> - 2017-03-07 01:00 +0100
Re: Question about hwmon_attr_show_string Jean Delvare <jdelvare@suse.de> - 2017-03-07 10:20 +0100
Re: Question about hwmon_attr_show_string Peter Huewe <peterhuewe@gmx.de> - 2017-03-07 10:30 +0100
Re: Question about hwmon_attr_show_string Guenter Roeck <linux@roeck-us.net> - 2017-03-07 16:10 +0100
csiph-web