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:	Tue, 19 Aug 2008 15:26:30 -0600
From:	Alex Chiang <achiang@...com>
To:	Rolf Eike Beer <eike-kernel@...tec.de>
Cc:	linux-kernel@...r.kernel.org, linux-pci@...r.kernel.org,
	jbarnes@...tuousgeek.org, kristen.c.accardi@...el.com,
	kaneshige.kenji@...fujitsu.com
Subject: Re: [PATCH 04/13] PCI: acpiphp: remove 'name' parameter

* Rolf Eike Beer <eike-kernel@...tec.de>:
> Alex Chiang wrote:
> > * Rolf Eike Beer <eike-kernel@...tec.de>:
> > > Alex Chiang wrote:
> > > >
> > > > +static inline const char *slot_name(struct slot *slot)
> > > > +{
> > > > +	return hotplug_slot_name(slot->hotplug_slot);
> > > > +}
> > > > +
> > > >  /*
> > > >   * struct acpiphp_bridge - PCI bridge information
> > > >   *
> > >
> > > I don't see a point in this function. Why not call hotplug_slot_name()
> > > directly?
> >
> > You're correct that we don't exactly need it in acpiphp. However,
> > it is a useful helper function for some of the other drivers, and
> > I thought it would be better to keep consistency if possible.
> 
> I looked into all other patches and the function is the same in every one.

For example, in shpchp, I use slot_name() in both shpchp_core.c
and in shpchp_ctrl.c. This is the case for a few other drivers
too.

Based on that reasoning, I felt a little consistency across
drivers was warranted. Besides, the generated code should be the
same.

> > > >  	acpiphp_slot->slot = slot;
> > > > -	snprintf(slot->name, sizeof(slot->name), "%u", slot->acpi_slot->sun);
> > > > +	memset(name, 0, SLOT_NAME_SIZE);
> > > > +	snprintf(name, SLOT_NAME_SIZE, "%u", slot->acpi_slot->sun);
> > >
> > > The memset() is not needed at all. And the sizeof is IMHO a good idea
> > > anyway as it allows to get rid of the define.
> >
> > Hm, don't need a memset? I won't have garbage on the stack?
> > </n00b>
> 
> Yes, you have garbage on the stack. But snprintf() does not care what is in 
> the buffer before it starts and the result is 0-terminated afterwards.

Ok, you're right. For some reason, I was thinking that there were
versions of snprintf() that did not NULL-terminate in the event
of truncation, but I checked the kernel implementation, and it
does NULL terminate in either case.

Besides, it looks like I should be using scnprintf() instead. So
I'll rework the patches.
 
> > On the other hand, keeping the #define is important, because
> > again, that's the established convention of the PCI hotplug
> > drivers.
> 
> I would not bet on this. It has been there and copied around
> from one driver to the other. If we can get rid of those I
> guess noone would be upset. And you introduced at least two of
> them ;) Jesse? 

The #define exists in the original pcihp_skeleton.c example.

This is perhaps the 2nd or 3rd time I've swept through the
PCI hotplug drivers for cleanups, and for me, I really prefer
some sort of consistency, otherwise I go insane trying to keep
track of the differences.

But I will defer to Jesse's opinion.

Thanks,

/ac

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ