All of lore.kernel.org
 help / color / mirror / Atom feed
* Why is device_create_file __must_check?
@ 2006-10-10  4:32 Paul Mackerras
  2006-10-10  4:49 ` Andrew Morton
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Mackerras @ 2006-10-10  4:32 UTC (permalink / raw)
  To: greg; +Cc: akpm, linux-kernel

I am seeing a bunch of warnings about not checking the return value
from device_create_file() for code like this (from
arch/powerpc/kernel/pci_64.c):

static ssize_t pci_show_devspec(struct device *dev,
		struct device_attribute *attr, char *buf)
{
	struct pci_dev *pdev;
	struct device_node *np;

	pdev = to_pci_dev (dev);
	np = pci_device_to_OF_node(pdev);
	if (np == NULL || np->full_name == NULL)
		return 0;
	return sprintf(buf, "%s", np->full_name);
}
static DEVICE_ATTR(devspec, S_IRUGO, pci_show_devspec, NULL);

void pcibios_add_platform_entries(struct pci_dev *pdev)
{
	device_create_file(&pdev->dev, &dev_attr_devspec);
}

What bad thing could happen if device_create_file fails, other than
that the "devspec" file doesn't appear in sysfs?  I don't see how the
error could lead to any null pointer dereference later on or anything
like that.  If some bad thing could happen, how do I avert that?  If
nothing bad will happen, why does device_create_file have __must_check
on it?

Paul.

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

end of thread, other threads:[~2006-10-10  7:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-10  4:32 Why is device_create_file __must_check? Paul Mackerras
2006-10-10  4:49 ` Andrew Morton
2006-10-10  5:04   ` Greg KH
2006-10-10  5:14   ` Paul Mackerras
2006-10-10  5:26     ` Andrew Morton
2006-10-10  7:03       ` Paul Mackerras
2006-10-10  5:27     ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.