# HG changeset patch # User Rob Landley # Date 1399746298 18000 # Node ID 29603c5a331774c497f37259c4faeaa1ec7cff5c # Parent 324306321d82c42eb9cf0fea66332948939349ca sizeof("string") treats it as a char array _including_ the null terminator, so strncmp(dest, "string", sizeof("string")) is just strcpy. diff -r 324306321d82 -r 29603c5a3317 toys/pending/last.c --- a/toys/pending/last.c Sat May 10 13:20:03 2014 -0500 +++ b/toys/pending/last.c Sat May 10 13:24:58 2014 -0500 @@ -138,7 +138,7 @@ curlog_type = RUN_LVL; } else if (ut.ut_type == BOOT_TIME) { seize_duration(tm[0], tm[1]); - strncpy(ut.ut_line, "system boot", sizeof("system boot")); + strcpy(ut.ut_line, "system boot"); free_list(); printf("%-8.8s %-12.12s %-*.*s %-16.16s %-7.7s %s\n", ut.ut_user, ut.ut_line, pwidth, pwidth, ut.ut_host, @@ -165,18 +165,18 @@ seize_duration(tm[0], tm[2]); switch (type) { case EMPTY: - strncpy(toybuf+18, " still", sizeof(" still")); - strncpy(toybuf+28, "logged in", sizeof("logged in")); + strcpy(toybuf+18, " still"); + strcpy(toybuf+28, "logged in"); break; case RUN_LVL: - strncpy(toybuf+18, "- down ", sizeof("- down ")); + strcpy(toybuf+18, "- down "); break; case BOOT_TIME: - strncpy(toybuf+18, "- crash", sizeof("- crash")); + strcpy(toybuf+18, "- crash"); break; case INIT_PROCESS: - strncpy(toybuf+18, " gone", sizeof(" gone")); - strncpy(toybuf+28, "- no logout", sizeof("- no logout")); + strcpy(toybuf+18, " gone"); + strcpy(toybuf+28, "- no logout"); break; default: break;