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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu,  9 Sep 2021 01:17:21 +0100
From:   Phillip Potter <phil@...lpotter.co.uk>
To:     hch@...radead.org
Cc:     axboe@...nel.dk, linux-kernel@...r.kernel.org, lumip@...ip.de,
        Phillip Potter <phil@...lpotter.co.uk>
Subject: Re: [PATCH v2] drivers/cdrom: improved ioctl for media change detection

> > +static int cdrom_ioctl_timed_media_change(struct cdrom_device_info *cdi,
> > +		unsigned long arg)
> > +{
> > +	int ret;
> > +	struct cdrom_timed_media_change_info __user *info;
> > +	struct cdrom_timed_media_change_info tmp_info;
> > +
> > +	if (!CDROM_CAN(CDC_MEDIA_CHANGED))
> > +		return -ENOSYS;
> > +
> > +	info = (struct cdrom_timed_media_change_info __user *)arg;
> > +	cd_dbg(CD_DO_IOCTL, "entering CDROM_TIMED_MEDIA_CHANGE\n");
> > +
> > +	ret = cdrom_ioctl_media_changed(cdi, CDSL_CURRENT);
> > +	if (ret < 0)
> > +		return ret;
> > +
> > +	if (copy_from_user(&tmp_info, info, sizeof(tmp_info)) != 0)
> > +		return -EFAULT;
> > +
> > +	tmp_info.has_changed = ((tmp_info.last_media_change - cdi->last_media_change_ms) < 0);
>
Dear Christoph,

Sorry didn't see this e-mail before I replied to Lukas, so I hope you
don't think I was ignoring you :-)

> Overly long line here, but more importantly this is much cleaner with
> a good old if:
>
>
>	if (tmp_info.last_media_change - cdi->last_media_change_ms) < 0)
>		tmp_info.has_changed = 1;
>

Whilst I don't disagree this is technically cleaner, the existing style
certainly read well to me. In terms of line length, checkpatch doesn't
complain about it, so I guess you mean purely from a visual perspective?

> > +{
> > +	__s64	last_media_change;	/* Timestamp of the last detected media
> > +					 * change in ms. May be set by caller, updated
> > +					 * upon successful return of ioctl.
> > +					 */
> > +	__u64	has_changed;		/* Set to 1 by ioctl if last detected media
>
> More overly long lines.  Also why is has_changed a u64 if it is used as
> a boolean flag?

As this is not a packed struct, would not a smaller value still take up
the same space?

As I'm keen to grow as a maintainer and take feedback, I can certainly
wait for Lukas to reply to this for sure.

Regards,
Phil

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ