← Commit list

f8d8aa1ce

Denys Vlasenko
Denys Vlasenko
2010-04-06
FAILED Duration: 28s

Subject

libbb: add skip_dev_pfx()

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

e2fsprogs/fsck.c+4 -4
@@ -169,12 +169,12 @@ static char *base_device(const char *device)
const char *disk;
int len;
#endif
- cp = str = xstrdup(device);
+ str = xstrdup(device);
- /* Skip over /dev/; if it's not present, give up. */
- if (strncmp(cp, "/dev/", 5) != 0)
+ /* Skip over "/dev/"; if it's not present, give up */
+ cp = skip_dev_pfx(str);
+ if (cp == str)
goto errout;
- cp += 5;
/*
* For md devices, we treat them all as if they were all
include/libbb.h+2 -0
@@ -263,6 +263,8 @@ extern void chomp(char *s) FAST_FUNC;
extern void trim(char *s) FAST_FUNC;
extern char *skip_whitespace(const char *) FAST_FUNC;
extern char *skip_non_whitespace(const char *) FAST_FUNC;
+extern char *skip_dev_pfx(const char *tty_name) FAST_FUNC;
+
extern char *strrstr(const char *haystack, const char *needle) FAST_FUNC;
//TODO: supply a pointer to char[11] buffer (avoid statics)?
init/init.c+1 -3
@@ -568,9 +568,7 @@ static void parse_inittab(void)
goto bad_entry;
/* turn .*TTY -> /dev/TTY */
if (tty[0]) {
- if (strncmp(tty, "/dev/", 5) == 0)
- tty += 5;
- tty = concat_path_file("/dev/", tty);
+ tty = concat_path_file("/dev/", skip_dev_pfx(tty));
}
new_init_action(1 << action, token[3], tty);
if (tty[0])
libbb/skip_whitespace.c+7 -0
@@ -30,3 +30,10 @@ char* FAST_FUNC skip_non_whitespace(const char *s)
return (char *) s;
}
+
+char* FAST_FUNC skip_dev_pfx(const char *tty_name)
+{
+ if (strncmp(tty_name, "/dev/", 5) == 0)
+ tty_name += 5;
+ return (char*)tty_name;
+}
libbb/utmp.c+0 -8
@@ -15,14 +15,6 @@ static void touch(const char *filename)
close(open(filename, O_WRONLY | O_CREAT, 0664));
}
-// TODO: move to libbb
-static const char* skip_dev_pfx(const char *tty_name)
-{
- if (strncmp(tty_name, "/dev/", 5) == 0)
- tty_name += 5;
- return tty_name;
-}
-
void FAST_FUNC write_new_utmp(pid_t pid, int new_type, const char *tty_name, const char *username, const char *hostname)
{
struct utmp utent;
loginutils/login.c+1 -3
@@ -249,9 +249,7 @@ int login_main(int argc UNUSED_PARAM, char **argv)
full_tty = xmalloc_ttyname(STDIN_FILENO);
if (!full_tty)
full_tty = xstrdup("UNKNOWN");
- short_tty = full_tty;
- if (strncmp(full_tty, "/dev/", 5) == 0)
- short_tty += 5;
+ short_tty = skip_dev_pfx(full_tty);
if (opt_host) {
fromhost = xasprintf(" on '%s' from '%s'", short_tty, opt_host);
util-linux/rtcwake.c+2 -3
@@ -35,9 +35,8 @@ static NOINLINE bool may_wakeup(const char *rtcname)
ssize_t ret;
char buf[128];
- /* strip the '/dev/' from the rtcname here */
- if (!strncmp(rtcname, "/dev/", 5))
- rtcname += 5;
+ /* strip "/dev/" from the rtcname here */
+ rtcname = skip_dev_pfx(rtcname);
snprintf(buf, sizeof(buf), SYS_RTC_PATH, rtcname);
ret = open_read_close(buf, buf, sizeof(buf));