public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Platform device matching, & weird strncmp usage
@ 2006-01-06  5:59 Benjamin Herrenschmidt
  2006-01-06  6:04 ` Benjamin Herrenschmidt
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Benjamin Herrenschmidt @ 2006-01-06  5:59 UTC (permalink / raw)
  To: Greg KH; +Cc: Linux Kernel list, Andrew Morton

Hi !

In 2.6.15, platform device matching works according to this comment in
the code, or rather are supposed to:


 *	Platform device IDs are assumed to be encoded like this:
 *	"<name><instance>", where <name> is a short description of the
 *	type of device, like "pci" or "floppy", and <instance> is the
 *	enumerated instance of the device, like '0' or '42'.

However, looking a few lines below, I see the actual implemetation:

static int platform_match(struct device * dev, struct device_driver * drv)
{
	struct platform_device *pdev = container_of(dev, struct platform_device, dev);

	return (strncmp(pdev->name, drv->name, BUS_ID_SIZE) == 0);
}

As far as I know, strncmp() is _NOT_ supposed to return 0 if one string
is shorter than the other and they match until that point. Thus the
above will never match unless the <name> portion of pdev->name is
exactly of size BUS_ID_SIZE which is obviously not the case...

Did I miss something or do we expect a "special" semantic for strncmp in
the kernel ?

Ben.



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

end of thread, other threads:[~2006-01-07 22:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-06  5:59 Platform device matching, & weird strncmp usage Benjamin Herrenschmidt
2006-01-06  6:04 ` Benjamin Herrenschmidt
2006-01-06 18:53 ` Russell King
2006-01-06 21:38   ` Benjamin Herrenschmidt
2006-01-07 19:24 ` Kurtis D. Rader
2006-01-07 19:42   ` Bob Copeland
2006-01-07 22:14   ` Benjamin Herrenschmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox