All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] udevd: Avoid implicit memset in match_attr()
Date: Sat, 25 Oct 2008 14:51:19 +0000	[thread overview]
Message-ID: <49033267.6000705@tuffmail.co.uk> (raw)

C initializers include an implicit "others => 0" (Ada syntax).
Initializing a char array to "" is equivalent to a memset()
call - which is exactly what it gets compiled to.

Fixing this one callsite reduced memset() _user_ cpu cycles
from 2-4% to 0.05% on the EeePC.

There are other occurences, but the fix isn't that pretty
so I left them alone.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>

diff --git a/udev/udev-rules.c b/udev/udev-rules.c
index 45806c3..ad2b00f 100644
--- a/udev/udev-rules.c
+++ b/udev/udev-rules.c
@@ -1559,10 +1559,11 @@ static int match_attr(struct udev_rules *rules, struct udev_device *dev, struct
 	char attr[UTIL_PATH_SIZE];
 	const char *key_name = &rules->buf[cur->key.attr_off];
 	const char *key_value = &rules->buf[cur->key.value_off];
-	char value[UTIL_NAME_SIZE] = "";
+	char value[UTIL_NAME_SIZE];
 	size_t len;
 
 	util_strlcpy(attr, key_name, sizeof(attr));
+	util_strlcpy(value, "", sizeof(value));
 	util_resolve_subsys_kernel(event->udev, attr, value, sizeof(value), 1);
 	if (value[0] = '\0') {
 		const char *val;



             reply	other threads:[~2008-10-25 14:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-25 14:51 Alan Jenkins [this message]
2008-10-25 17:44 ` [PATCH] udevd: Avoid implicit memset in match_attr() Kay Sievers
2008-10-25 18:13 ` Alan Jenkins
2008-10-26  1:38 ` Kay Sievers

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=49033267.6000705@tuffmail.co.uk \
    --to=alan-jenkins@tuffmail.co.uk \
    --cc=linux-hotplug@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.