linux-edac.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* sysfs output without newlines
@ 2020-08-29 18:23 Joe Perches
  2020-08-29 20:23 ` Denis Efremov
  2020-08-30  9:11 ` Greg Kroah-Hartman
  0 siblings, 2 replies; 5+ messages in thread
From: Joe Perches @ 2020-08-29 18:23 UTC (permalink / raw)
  To: LKML, Denis Efremov, Greg Kroah-Hartman, Rafael J. Wysocki,
	Kees Cook, Gustavo A . R . Silva, Julia Lawall, Alex Dewar
  Cc: York Sun, Borislav Petkov, Mauro Carvalho Chehab, Tony Luck,
	James Morse, Robert Richter, Michal Simek, Boris Brezillon,
	Maxim Levitsky, Alex Dubov, Ulf Hansson, Tomas Winkler,
	Arnd Bergmann, Madalin Bucur, David S. Miller, Jakub Kicinski,
	Douglas Miller, Stanislav Yakovlev, Kalle Valo, Darren Hart,
	Andy Shevchenko, Kai Mäkisara, James E.J. Bottomley,
	Martin K. Petersen, Mark Brown, Oliver Neukum, Pete Zaitcev,
	linux-edac, linux-arm-kernel, linux-i3c, linux-mmc, netdev,
	linux-wireless, platform-driver-x86, linux-scsi, linux-spi,
	linux-usb

While doing an investigation for a possible treewide conversion of
sysfs output using sprintf/snprintf/scnprintf, I discovered
several instances of sysfs output without terminating newlines.

It seems likely all of these should have newline terminations
or have the \n\r termination changed to a single newline.

Anyone have any objection to patches adding newlines to these
in their original forms using sprintf/snprintf/scnprintf?

A few of these might be false positives as
	"%s", string
might already have string with a newline termination.

+++ drivers/edac/fsl_ddr_edac.c
+	return sysfs_emit(data, "0x%08x",
+	return sysfs_emit(data, "0x%08x",
+	return sysfs_emit(data, "0x%08x",
+++ drivers/edac/synopsys_edac.c
+	return sysfs_emit(data, "Data Poisoning: %s\n\r",
+		return sysfs_emit(buf, "1");
+		return sysfs_emit(buf, "0");
+		return sysfs_emit(buf, "1");
+		return sysfs_emit(buf, "0");
+		return sysfs_emit(buf, "0");
+		return sysfs_emit(buf, "1");
+		return sysfs_emit(buf, "0");
+	return sysfs_emit(buf, "%u", !!(data->status & mask));
+	return sysfs_emit(buf, "%u", data->tcrit2[index] * 1000);
+	return sysfs_emit(buf, "%d",
+	return sysfs_emit(buf, "%u", data->tcrit1[index] * 1000);
+	return sysfs_emit(buf, "%d",
+	return sysfs_emit(buf, "%d", data->toffset[index] * 500);
+++ drivers/i3c/master.c
+		return sysfs_emit(buf, "i3c:dcr%02Xmanuf%04X", devinfo.dcr,
+	return sysfs_emit(buf, "i3c:dcr%02Xmanuf%04Xpart%04Xext%04X",
+	return sysfs_emit(buf, "%s", dd->boardversion);
+	return sysfs_emit(buf, "%s", dd->serial);
+	return sysfs_emit(buf, "%s", (char *)ib_qib_version);
+	return sysfs_emit(buf, "%s", dd->boardversion);
+	return sysfs_emit(buf, "%s", dd->lbus_info);
+	return sysfs_emit(buf, "ipac:f%02Xv%08Xd%08X", idev->id_format,
+++ drivers/memstick/core/mspro_block.c
+	return sysfs_emit(buffer, "%s", (char *)s_attr->data);
+	return sysfs_emit(buf, "%s",
+	return sysfs_emit(buf, "%s",
+++ drivers/misc/mei/bus.c
+	return sysfs_emit(buf, "%s", cldev->name);
+	return sysfs_emit(buf, "%pUl", uuid);
+	return sysfs_emit(buf, "%02X", version);
+	return sysfs_emit(buf, "mei:%s:%pUl:%02X:",
+	return sysfs_emit(buf, "%d", maxconn);
+	return sysfs_emit(buf, "%d", fixed);
+	return sysfs_emit(buf, "%d", vt);
+	return sysfs_emit(buf, "%u", maxlen);
+	return sysfs_emit(buf, "%s", mei_dev_state_str(dev_state));
+++ drivers/misc/tifm_core.c
+	return sysfs_emit(buf, "%x", sock->type);
+			return sysfs_emit(buf, "%s",
+	return sysfs_emit(buf, "%d", dev->net_count);
+++ drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c
+		return sysfs_emit(buf, "%llx",
+		return sysfs_emit(buf, "none");
+++ drivers/net/ethernet/ibm/ehea/ehea_main.c
+	return sysfs_emit(buf, "%d", port->logical_port_id);
+++ drivers/net/wireless/intel/ipw2x00/ipw2200.c
+		return sysfs_emit(buf, "%s", priv->prom_net_dev->name);
+	return sysfs_emit(buf, "0x%04X",
+	return sysfs_emit(buf, "%d", il->retry_rate);
+	return sysfs_emit(buf, "%pOF", np);
+	return sysfs_emit(buf, "pcmcia:m%04Xc%04Xf%02Xfn%02Xpfn%02X"
+++ drivers/platform/x86/dell-smbios-base.c
+		return sysfs_emit(buf, "%08x", da_tokens[i].location);
+		return sysfs_emit(buf, "%08x", da_tokens[i].value);
+	return sysfs_emit(buf, "%08x",
+++ drivers/scsi/st.c
+	return sysfs_emit(buf, "%lld",
+	return sysfs_emit(buf, "%lld",
+	return sysfs_emit(buf, "%lld",
+	return sysfs_emit(buf, "%lld",
+	return sysfs_emit(buf, "%lld",
+	return sysfs_emit(buf, "%lld",
+	return sysfs_emit(buf, "%lld",
+	return sysfs_emit(buf, "%lld",
+	return sysfs_emit(buf, "%lld",
+	return sysfs_emit(buf, "%lld",
+++ drivers/spi/spi-tle62x0.c
+	return sysfs_emit(buf, "%d", value);
+++ drivers/usb/class/cdc-acm.c
+	return sysfs_emit(buf, "%d", acm->ctrl_caps);
+	return sysfs_emit(buf, "%d", acm->country_rel_date);
+++ drivers/usb/class/usblp.c
+	return sysfs_emit(buf, "%s", usblp->device_id_string+2);
+	return sysfs_emit(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02X"
+++ drivers/usb/misc/cytherm.c
+	return sysfs_emit(buf, "%i", cytherm->brightness);
+	return sysfs_emit(buf, "%c%i.%i", sign ? '-' : '+', temp >> 1,
+		return sysfs_emit(buf, "1");
+		return sysfs_emit(buf, "0");
+	return sysfs_emit(buf, "%d", retval);
+	return sysfs_emit(buf, "%d", retval);



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: sysfs output without newlines
  2020-08-29 18:23 sysfs output without newlines Joe Perches
@ 2020-08-29 20:23 ` Denis Efremov
  2020-08-29 20:33   ` Joe Perches
  2020-08-30  9:11 ` Greg Kroah-Hartman
  1 sibling, 1 reply; 5+ messages in thread
From: Denis Efremov @ 2020-08-29 20:23 UTC (permalink / raw)
  To: Joe Perches, LKML, Greg Kroah-Hartman, Rafael J. Wysocki,
	Kees Cook, Gustavo A . R . Silva, Julia Lawall, Alex Dewar
  Cc: York Sun, Borislav Petkov, Mauro Carvalho Chehab, Tony Luck,
	James Morse, Robert Richter, Michal Simek, Boris Brezillon,
	Maxim Levitsky, Alex Dubov, Ulf Hansson, Tomas Winkler,
	Arnd Bergmann, Madalin Bucur, David S. Miller, Jakub Kicinski,
	Douglas Miller, Stanislav Yakovlev, Kalle Valo, Darren Hart,
	Andy Shevchenko, Kai Mäkisara, James E.J. Bottomley,
	Martin K. Petersen, Mark Brown, Oliver Neukum, Pete Zaitcev,
	linux-edac, linux-arm-kernel, linux-i3c, linux-mmc, netdev,
	linux-wireless, platform-driver-x86, linux-scsi, linux-spi,
	linux-usb

Hi,

On 8/29/20 9:23 PM, Joe Perches wrote:
> While doing an investigation for a possible treewide conversion of
> sysfs output using sprintf/snprintf/scnprintf, I discovered
> several instances of sysfs output without terminating newlines.
> 
> It seems likely all of these should have newline terminations
> or have the \n\r termination changed to a single newline.

I think that it could break badly written scripts in rare cases.

> 
> Anyone have any objection to patches adding newlines to these
> in their original forms using sprintf/snprintf/scnprintf?

I'm not sure about existing cases, but I think it's a good
checkpatch.pl warning for new patches. It should be 
possible to check sysfs_emit() calls.

Thanks,
Denis

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: sysfs output without newlines
  2020-08-29 20:23 ` Denis Efremov
@ 2020-08-29 20:33   ` Joe Perches
  2020-09-01  9:07     ` David Laight
  0 siblings, 1 reply; 5+ messages in thread
From: Joe Perches @ 2020-08-29 20:33 UTC (permalink / raw)
  To: Denis Efremov, LKML, Greg Kroah-Hartman, Rafael J. Wysocki,
	Kees Cook, Gustavo A . R . Silva, Julia Lawall, Alex Dewar
  Cc: York Sun, Borislav Petkov, Mauro Carvalho Chehab, Tony Luck,
	James Morse, Robert Richter, Michal Simek, Boris Brezillon,
	Maxim Levitsky, Alex Dubov, Ulf Hansson, Tomas Winkler,
	Arnd Bergmann, Madalin Bucur, David S. Miller, Jakub Kicinski,
	Douglas Miller, Stanislav Yakovlev, Kalle Valo, Darren Hart,
	Andy Shevchenko, Kai Mäkisara, James E.J. Bottomley,
	Martin K. Petersen, Mark Brown, Oliver Neukum, Pete Zaitcev,
	linux-edac, linux-arm-kernel, linux-i3c, linux-mmc, netdev,
	linux-wireless, platform-driver-x86, linux-scsi, linux-spi,
	linux-usb

On Sat, 2020-08-29 at 23:23 +0300, Denis Efremov wrote:
> Hi,
> 
> On 8/29/20 9:23 PM, Joe Perches wrote:
> > While doing an investigation for a possible treewide conversion of
> > sysfs output using sprintf/snprintf/scnprintf, I discovered
> > several instances of sysfs output without terminating newlines.
> > 
> > It seems likely all of these should have newline terminations
> > or have the \n\r termination changed to a single newline.
> 
> I think that it could break badly written scripts in rare cases.

Maybe.

Is sysfs output a nominally unchangeable api like seq_?
Dunno.  seq_ output is extended all the time.

I think whitespace isn't generally considered part of
sscanf type input content awareness.

> > Anyone have any objection to patches adding newlines to these
> > in their original forms using sprintf/snprintf/scnprintf?
> 
> I'm not sure about existing cases, but I think it's a good
> checkpatch.pl warning for new patches. It should be 
> possible to check sysfs_emit() calls.

Eventually, yes.

cheers, Joe


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: sysfs output without newlines
  2020-08-29 18:23 sysfs output without newlines Joe Perches
  2020-08-29 20:23 ` Denis Efremov
@ 2020-08-30  9:11 ` Greg Kroah-Hartman
  1 sibling, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2020-08-30  9:11 UTC (permalink / raw)
  To: Joe Perches
  Cc: LKML, Denis Efremov, Rafael J. Wysocki, Kees Cook,
	Gustavo A . R . Silva, Julia Lawall, Alex Dewar, York Sun,
	Borislav Petkov, Mauro Carvalho Chehab, Tony Luck, James Morse,
	Robert Richter, Michal Simek, Boris Brezillon, Maxim Levitsky,
	Alex Dubov, Ulf Hansson, Tomas Winkler, Arnd Bergmann,
	Madalin Bucur, David S. Miller, Jakub Kicinski, Douglas Miller,
	Stanislav Yakovlev, Kalle Valo, Darren Hart, Andy Shevchenko,
	Kai Mäkisara, James E.J. Bottomley, Martin K. Petersen,
	Mark Brown, Oliver Neukum, Pete Zaitcev, linux-edac,
	linux-arm-kernel, linux-i3c, linux-mmc, netdev, linux-wireless,
	platform-driver-x86, linux-scsi, linux-spi, linux-usb

On Sat, Aug 29, 2020 at 11:23:43AM -0700, Joe Perches wrote:
> While doing an investigation for a possible treewide conversion of
> sysfs output using sprintf/snprintf/scnprintf, I discovered
> several instances of sysfs output without terminating newlines.
> 
> It seems likely all of these should have newline terminations
> or have the \n\r termination changed to a single newline.
> 
> Anyone have any objection to patches adding newlines to these
> in their original forms using sprintf/snprintf/scnprintf?

No objection for me, patches for my subsystems will be gladly taken.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: sysfs output without newlines
  2020-08-29 20:33   ` Joe Perches
@ 2020-09-01  9:07     ` David Laight
  0 siblings, 0 replies; 5+ messages in thread
From: David Laight @ 2020-09-01  9:07 UTC (permalink / raw)
  To: 'Joe Perches',
	Denis Efremov, LKML, Greg Kroah-Hartman, Rafael J. Wysocki,
	Kees Cook, Gustavo A . R . Silva, Julia Lawall, Alex Dewar
  Cc: York Sun, Borislav Petkov, Mauro Carvalho Chehab, Tony Luck,
	James Morse, Robert Richter, Michal Simek, Boris Brezillon,
	Maxim Levitsky, Alex Dubov, Ulf Hansson, Tomas Winkler,
	Arnd Bergmann, Madalin Bucur, David S. Miller, Jakub Kicinski,
	Douglas Miller, Stanislav Yakovlev, Kalle Valo, Darren Hart,
	Andy Shevchenko, Kai Mäkisara, James E.J. Bottomley,
	Martin K. Petersen, Mark Brown, Oliver Neukum, Pete Zaitcev,
	linux-edac, linux-arm-kernel, linux-i3c, linux-mmc, netdev,
	linux-wireless, platform-driver-x86, linux-scsi, linux-spi,
	linux-usb

From: Joe Perches
> Sent: 29 August 2020 21:34
...
> > On 8/29/20 9:23 PM, Joe Perches wrote:
> > > While doing an investigation for a possible treewide conversion of
> > > sysfs output using sprintf/snprintf/scnprintf, I discovered
> > > several instances of sysfs output without terminating newlines.
> > >
> > > It seems likely all of these should have newline terminations
> > > or have the \n\r termination changed to a single newline.
> >
> > I think that it could break badly written scripts in rare cases.
> 
> Maybe.
> 
> Is sysfs output a nominally unchangeable api like seq_?
> Dunno.  seq_ output is extended all the time.
> 
> I think whitespace isn't generally considered part of
> sscanf type input content awareness.

The shell will remove trailing '\n' (but not '\r') from:
	foo=$(cat bar)
So shell scripts are unlikely to be affected.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-09-01  9:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-29 18:23 sysfs output without newlines Joe Perches
2020-08-29 20:23 ` Denis Efremov
2020-08-29 20:33   ` Joe Perches
2020-09-01  9:07     ` David Laight
2020-08-30  9:11 ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).