On Wed, Jun 18, 2025 at 08:30:10AM -0700, Luck, Tony wrote: > On Wed, Jun 18, 2025 at 06:21:39PM +0300, Dan Carpenter wrote: > > On Thu, Jun 12, 2025 at 04:13:25PM -0700, Zaid Alali wrote: > > > +static ssize_t u128_read(struct file *f, char __user *buf, size_t count, > > > loff_t *off) > > > +{ > > > + char output[2 * COMPONENT_LEN + 1]; > > > + u8 *data = f->f_inode->i_private; > > > + int i; > > > + > > > + if (*off >= sizeof(output)) > > > + return 0; > > > > No need for this check. simple_read_from_buffer() will do the > > right thing. > > True. But why waste cycles populating the output buffer > when it will be ignored? The normal flow here is that > a user will likely try to read a <stdio.h> sized buffer > and get back 33 bytes. Then read again to find EOF. That > second read doesn't need to do all the "sprintf()"s. >
Ah. Okay, I didn't realize that. regards, dan carpenter