From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: MyungJoo Ham <myungjoo.ham@samsung.com>,
Chanwoo Choi <cw00.choi@samsung.com>,
linux-kernel@vger.kernel.org, Hans de Goede <hdegoede@redhat.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 2/7] extcon: Switch to use kasprintf() instead of open coded
Date: Mon, 27 Aug 2018 18:35:52 +0300 [thread overview]
Message-ID: <20180827153557.58363-2-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20180827153557.58363-1-andriy.shevchenko@linux.intel.com>
Switch to use kasprintf() instead of open coded variant.
No functional change intended.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/extcon/extcon.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
index c21650a92689..5ab0498be652 100644
--- a/drivers/extcon/extcon.c
+++ b/drivers/extcon/extcon.c
@@ -1123,7 +1123,6 @@ int extcon_dev_register(struct extcon_dev *edev)
(unsigned long)atomic_inc_return(&edev_no));
if (edev->max_supported) {
- char buf[10];
char *str;
struct extcon_cable *cable;
@@ -1137,9 +1136,7 @@ int extcon_dev_register(struct extcon_dev *edev)
for (index = 0; index < edev->max_supported; index++) {
cable = &edev->cables[index];
- snprintf(buf, 10, "cable.%d", index);
- str = kzalloc(strlen(buf) + 1,
- GFP_KERNEL);
+ str = kasprintf(GFP_KERNEL, "cable.%d", index);
if (!str) {
for (index--; index >= 0; index--) {
cable = &edev->cables[index];
@@ -1149,7 +1146,6 @@ int extcon_dev_register(struct extcon_dev *edev)
goto err_alloc_cables;
}
- strcpy(str, buf);
cable->edev = edev;
cable->cable_index = index;
@@ -1172,7 +1168,6 @@ int extcon_dev_register(struct extcon_dev *edev)
}
if (edev->max_supported && edev->mutually_exclusive) {
- char buf[80];
char *name;
/* Count the size of mutually_exclusive array */
@@ -1197,9 +1192,8 @@ int extcon_dev_register(struct extcon_dev *edev)
}
for (index = 0; edev->mutually_exclusive[index]; index++) {
- sprintf(buf, "0x%x", edev->mutually_exclusive[index]);
- name = kzalloc(strlen(buf) + 1,
- GFP_KERNEL);
+ name = kasprintf(GFP_KERNEL, "0x%x",
+ edev->mutually_exclusive[index]);
if (!name) {
for (index--; index >= 0; index--) {
kfree(edev->d_attrs_muex[index].attr.
@@ -1210,7 +1204,6 @@ int extcon_dev_register(struct extcon_dev *edev)
ret = -ENOMEM;
goto err_muex;
}
- strcpy(name, buf);
sysfs_attr_init(&edev->d_attrs_muex[index].attr);
edev->d_attrs_muex[index].attr.name = name;
edev->d_attrs_muex[index].attr.mode = 0000;
--
2.18.0
next prev parent reply other threads:[~2018-08-27 15:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20180827153615epcas5p212a6279a5d5c3cbfc2608cbf34c2803d@epcas5p2.samsung.com>
2018-08-27 15:35 ` [PATCH v1 1/7] extcon: Make static analyzer happy about union assignment Andy Shevchenko
2018-08-27 15:35 ` Andy Shevchenko [this message]
2018-08-29 9:40 ` [PATCH v1 2/7] extcon: Switch to use kasprintf() instead of open coded David Laight
2018-08-27 15:35 ` [PATCH v1 3/7] extcon: cht-wc: Return from default case to avoid warnings Andy Shevchenko
2018-08-27 15:35 ` [PATCH v1 4/7] extcon: cht-wc: Fix definition names according to spec Andy Shevchenko
2018-08-27 15:35 ` [PATCH v1 5/7] extcon: cht-wc: Correct USBID bit field handling Andy Shevchenko
2018-08-27 15:35 ` [PATCH v1 6/7] extcon: cht-wc: Convert to use SPDX identifier Andy Shevchenko
2018-08-27 15:35 ` [PATCH v1 7/7] extcon: int3496: " Andy Shevchenko
2018-08-29 7:06 ` [PATCH v1 1/7] extcon: Make static analyzer happy about union assignment Chanwoo Choi
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=20180827153557.58363-2-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=cw00.choi@samsung.com \
--cc=hdegoede@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
/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).