lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 6 May 2020 08:51:34 +0200
From:   Greg KH <greg@...ah.com>
To:     Akira shimahara <akira215corp@...il.com>
Cc:     zbr@...emap.net, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 1/9] w1_therm: creating w1_therm.h

On Tue, May 05, 2020 at 11:04:39PM +0200, Akira shimahara wrote:
> Le mardi 05 mai 2020 à 16:48 +0200, Greg KH a écrit :
> > > Creating w1_therm.h header to organize code. Organize the
> > > w1_therm.c file
> > > to gather hardware functions, device specific functions, interface
> > > functions and sysfs functions.
> > > Signed-off-by: Akira Shimahara <akira215corp@...il.com>
> > > ---
> > >   drivers/w1/slaves/w1_therm.c | 302 +++++++++++++++---------------
> > > -----
> > >   drivers/w1/slaves/w1_therm.h | 138 ++++++++++++++++
> > >   2 files changed, 269 insertions(+), 171 deletions(-)
> > >   create mode 100644 drivers/w1/slaves/w1_therm.h
> > 
> > 
> > Wait, why is a .h file needed for just a single .c file?
> > 
> > 
> > 
> > 
> > 
> > <snip>
> > 
> > 
> > 
> > >   static ssize_t read_therm(struct device *device,
> > 
> > 
> > 
> > 
> > > +/** read_therm()
> > > + * @param sl pointer to the slave to read
> > > + * @param info pointer to a structure to store the read results
> > > + * @return 0 if success, -kernel error code otherwise
> > > + */
> > > +static ssize_t read_therm(struct device *device,
> > > +                     struct w1_slave *sl, struct therm_info
> > > *info);
> > > +
> > 
> > 
> > Why is this function needed to be declared in this .h file?
> > 
> > 
> > 
> > Why is any of this needed?  For some reason I thought you needed a .h
> > 
> > file to make things simpler for other .c files, but if all of this is
> > 
> > static, it's not needed at all, right?
> > 
> > 
> > 
> > thanks,
> > 
> > 
> > 
> > greg k-h
> 
> Hello,
> 
> Yes, you are right, header file could be avoided. But we separate it
> from .c for clarity purpose, and to ease future developpment (for
> example adding support of new devices).
> 
> If you absolutely want to put everything in the .c file, I can do it,
> let me know.

Keep it all in a .c file, only use .h files for when you need to share
it across multiple .c files, otherwise it's not needed.

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ