summaryrefslogtreecommitdiffstats
path: root/login-utils/lslogins.c
diff options
context:
space:
mode:
authorRuediger Meier2016-12-01 09:52:06 +0100
committerKarel Zak2016-12-07 12:35:24 +0100
commit77f5a945868e9a2bf9fe71bfdbe8bf54a2441699 (patch)
tree20ca2f4c50e3f4304be011b678af772724e3ca71 /login-utils/lslogins.c
parentlogin-utils: remove _HAVE_UT_TV fallback (diff)
downloadkernel-qcow2-util-linux-77f5a945868e9a2bf9fe71bfdbe8bf54a2441699.tar.gz
kernel-qcow2-util-linux-77f5a945868e9a2bf9fe71bfdbe8bf54a2441699.tar.xz
kernel-qcow2-util-linux-77f5a945868e9a2bf9fe71bfdbe8bf54a2441699.zip
lslogins: remove useless strlen()
strlen() is not smarter than strncpy(). Bytes that follow a null byte are not compared anyway. BTW avoid using the defined sizes. CC: Ondrej Oprala <ooprala@redhat.com> Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Diffstat (limited to 'login-utils/lslogins.c')
-rw-r--r--login-utils/lslogins.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index 78d4ed46f..410987646 100644
--- a/login-utils/lslogins.c
+++ b/login-utils/lslogins.c
@@ -413,16 +413,14 @@ again:
static struct utmp *get_last_wtmp(struct lslogins_control *ctl, const char *username)
{
size_t n = 0;
- size_t len;
if (!username)
return NULL;
- len = strlen(username);
n = ctl->wtmp_size - 1;
do {
if (!strncmp(username, ctl->wtmp[n].ut_user,
- len < UT_NAMESIZE ? len : UT_NAMESIZE))
+ sizeof(ctl->wtmp[0].ut_user)))
return ctl->wtmp + n;
} while (n--);
return NULL;
@@ -450,16 +448,14 @@ static int require_btmp(void)
static struct utmp *get_last_btmp(struct lslogins_control *ctl, const char *username)
{
size_t n = 0;
- size_t len;
if (!username)
return NULL;
- len = strlen(username);
n = ctl->btmp_size - 1;
do {
if (!strncmp(username, ctl->btmp[n].ut_user,
- len < UT_NAMESIZE ? len : UT_NAMESIZE))
+ sizeof(ctl->wtmp[0].ut_user)))
return ctl->btmp + n;
}while (n--);
return NULL;