From: Alex Chiang <achiang@hp.com>
To: Rolf Eike Beer <eike-kernel@sf-tec.de>
Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
jbarnes@virtuousgeek.org, kristen.c.accardi@intel.com,
kaneshige.kenji@jp.fujitsu.com
Subject: Re: [PATCH 04/13] PCI: acpiphp: remove 'name' parameter
Date: Tue, 19 Aug 2008 15:26:30 -0600 [thread overview]
Message-ID: <20080819212630.GF18842@ldl.fc.hp.com> (raw)
In-Reply-To: <200808192301.56532.eike-kernel@sf-tec.de>
* Rolf Eike Beer <eike-kernel@sf-tec.de>:
> Alex Chiang wrote:
> > * Rolf Eike Beer <eike-kernel@sf-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
next prev parent reply other threads:[~2008-08-19 21:27 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-17 0:14 [PATCH 00/13] PCI: let the core manage slot names Alex Chiang
2008-08-17 0:15 ` [PATCH 01/13] PCI Hotplug core: add 'name' param pci_hp_register interface Alex Chiang
2008-08-17 0:16 ` [PATCH 02/13] PCI: prevent duplicate slot names Alex Chiang
2008-08-21 10:24 ` Kenji Kaneshige
2008-09-09 9:04 ` Alex Chiang
2008-09-11 2:43 ` Kenji Kaneshige
2008-09-09 10:00 ` [PATCH v2 00/13] PCI: let the core manage " Alex Chiang
2008-09-09 10:00 ` [PATCH v2 01/13] PCI Hotplug core: add 'name' param pci_hp_register interface Alex Chiang
2008-09-09 12:05 ` Matthew Wilcox
2008-09-09 17:18 ` Alex Chiang
2008-09-09 10:00 ` [PATCH v2 02/13] PCI: prevent duplicate slot names Alex Chiang
2008-09-09 13:07 ` Matthew Wilcox
2008-09-22 21:38 ` Alex Chiang
2008-09-22 22:42 ` Matthew Wilcox
2008-09-10 14:58 ` Rolf Eike Beer
2008-09-22 21:40 ` Alex Chiang
2008-09-11 2:47 ` Kenji Kaneshige
2008-09-11 10:37 ` Alex Chiang
2008-09-23 0:05 ` Alex Chiang
2008-09-09 10:00 ` [PATCH v2 03/13] PCI, PCI Hotplug: introduce slot_name helpers Alex Chiang
2008-09-09 14:30 ` Matthew Wilcox
2008-09-09 10:00 ` [PATCH v2 04/13] PCI: acpiphp: remove 'name' parameter Alex Chiang
2008-09-09 14:38 ` Matthew Wilcox
2008-09-23 1:16 ` Alex Chiang
2008-09-09 10:00 ` [PATCH v2 05/13] PCI: cpci_hotplug: stop managing hotplug_slot->name Alex Chiang
2008-09-09 15:04 ` Matthew Wilcox
2008-09-09 21:11 ` Scott Murray
2008-09-09 10:00 ` [PATCH v2 06/13] PCI: cpqphp: " Alex Chiang
2008-09-09 15:08 ` Matthew Wilcox
2008-09-23 1:20 ` Alex Chiang
2008-09-09 10:00 ` [PATCH v2 07/13] PCI: fakephp: remove 'name' parameter Alex Chiang
2008-09-09 10:00 ` [PATCH v2 08/13] PCI: ibmphp: stop managing hotplug_slot->name Alex Chiang
2008-09-09 10:00 ` [PATCH v2 09/13] PCI: pciehp: remove 'name' parameter Alex Chiang
2008-09-09 10:00 ` [PATCH v2 10/13] PCI: rpaphp: stop managing hotplug_slot->name Alex Chiang
2008-09-09 10:00 ` [PATCH v2 11/13] PCI: SGI Hotplug: stop managing bss_hotplug_slot->name Alex Chiang
2008-09-09 10:01 ` [PATCH v2 12/13] PCI: shcphp: remove 'name' parameter Alex Chiang
2008-09-09 10:01 ` [PATCH v2 13/13] PCI: Hotplug core: remove 'name' Alex Chiang
2008-08-17 0:16 ` [PATCH 03/13] PCI, PCI Hotplug: introduce slot_name helpers Alex Chiang
2008-08-17 0:16 ` [PATCH 04/13] PCI: acpiphp: remove 'name' parameter Alex Chiang
2008-08-17 8:59 ` Rolf Eike Beer
2008-08-19 18:39 ` Alex Chiang
2008-08-19 21:01 ` Rolf Eike Beer
2008-08-19 21:26 ` Alex Chiang [this message]
2008-08-19 21:40 ` Jesse Barnes
2008-08-19 23:50 ` Alex Chiang
2008-08-20 2:25 ` Kenji Kaneshige
2008-08-17 0:16 ` [PATCH 05/13] PCI: cpci_hotplug: stop managing hotplug_slot->name Alex Chiang
2008-08-17 0:16 ` [PATCH 06/13] PCI: cpqphp: " Alex Chiang
2008-08-17 0:17 ` [PATCH 07/13] PCI: fakephp: remove 'name' parameter Alex Chiang
2008-08-17 0:17 ` [PATCH 08/13] PCI: ibmphp: stop managing hotplug_slot->name Alex Chiang
2008-08-17 0:17 ` [PATCH 09/13] PCI: pciehp: remove 'name' parameter Alex Chiang
2008-08-17 0:17 ` [PATCH 10/13] PCI: rpaphp: stop managing hotplug_slot->name Alex Chiang
2008-08-17 0:17 ` [PATCH 11/13] PCI: SGI Hotplug: stop managing bss_hotplug_slot->name Alex Chiang
2008-08-17 0:17 ` [PATCH 12/13] PCI: shcphp: remove 'name' parameter Alex Chiang
2008-08-17 0:17 ` [PATCH 13/13] PCI: Hotplug core: remove 'name' Alex Chiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080819212630.GF18842@ldl.fc.hp.com \
--to=achiang@hp.com \
--cc=eike-kernel@sf-tec.de \
--cc=jbarnes@virtuousgeek.org \
--cc=kaneshige.kenji@jp.fujitsu.com \
--cc=kristen.c.accardi@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).