From: tip-bot for Julia Lawall <julia@diku.dk>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, julia@diku.dk, hpa@zytor.com,
mingo@redhat.com, akpm@linux-foundation.org, tglx@linutronix.de,
hpa@linux.intel.com
Subject: [tip:x86/urgent] arch/x86/pci: use kasprintf
Date: Mon, 24 May 2010 23:07:07 GMT [thread overview]
Message-ID: <tip-b46fc5f235be04a7f77fb2af1d8cb809889c25c1@git.kernel.org> (raw)
In-Reply-To: <201005241913.o4OJDG3R010871@imap1.linux-foundation.org>
Commit-ID: b46fc5f235be04a7f77fb2af1d8cb809889c25c1
Gitweb: http://git.kernel.org/tip/b46fc5f235be04a7f77fb2af1d8cb809889c25c1
Author: Julia Lawall <julia@diku.dk>
AuthorDate: Mon, 24 May 2010 12:13:16 -0700
Committer: H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Mon, 24 May 2010 13:31:45 -0700
arch/x86/pci: use kasprintf
kasprintf combines kmalloc and sprintf, and takes care of the size
calculation itself.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression a,flag;
expression list args;
statement S;
@@
a =
- \(kmalloc\|kzalloc\)(...,flag)
+ kasprintf(flag,args)
<... when != a
if (a == NULL || ...) S
...>
- sprintf(a,args);
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
LKML-Reference: <201005241913.o4OJDG3R010871@imap1.linux-foundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
arch/x86/pci/acpi.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 31930fd..7c0ad63 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -207,10 +207,9 @@ get_current_resources(struct acpi_device *device, int busnum,
if (!info.res)
goto res_alloc_fail;
- info.name = kmalloc(16, GFP_KERNEL);
+ info.name = kasprintf(GFP_KERNEL, "PCI Bus %04x:%02x", domain, busnum);
if (!info.name)
goto name_alloc_fail;
- sprintf(info.name, "PCI Bus %04x:%02x", domain, busnum);
info.res_num = 0;
acpi_walk_resources(device->handle, METHOD_NAME__CRS, setup_resource,
parent reply other threads:[~2010-05-24 23:07 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <201005241913.o4OJDG3R010871@imap1.linux-foundation.org>]
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=tip-b46fc5f235be04a7f77fb2af1d8cb809889c25c1@git.kernel.org \
--to=julia@diku.dk \
--cc=akpm@linux-foundation.org \
--cc=hpa@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/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
Powered by JetHome