Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1593713

Question about hwmon_attr_show_string

From Peter Hüwe <PeterHuewe@gmx.de>
Newsgroups linux.kernel
Subject Question about hwmon_attr_show_string
Date 2017-03-06 21:50 +0100
Message-ID <ti7JU-5av-21@gated-at.bofh.it> (permalink)
References <tgJqh-1AZ-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.


Unfortunately there are no other callers, where you show the intended usage.



Thanks,
Peter

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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