Re: get info in a loop from a sysfs entry

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 01/04/2011 04:52 PM, Dave Hylands wrote:
> On Tue, Jan 4, 2011 at 2:48 AM, Wouter Simons <lkml@xxxxxxxxxxxxxxxx> wrote:
>>
>> for (i = 0; i < count; i++) {
>>        if (fscanf(fd_next, "0x%X", &sample) != 1) { /* No data */
>>                continue;
>>        }
> 
> I would change this to use unbuffered I/O routines (i.e.
> open/read/lseek/close) and use sscanf rather than fscanf.
> fopen/fread/fseek/fclose use buffering by default.
> 
> That would eliminate any buffering that the user side runtime library
> is doing. I suspect that because the data is buffered by the FILE *
> routines, even doing the seek is just re-returning the data that was
> read the first time around.

Thanks Dave, a quick test application shows that your solution works
perfectly. This saves me a lot of overhead!

Best regards,

Wouter

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux