Skip to content

Commit 0936d4f

Browse files
mhiramatrichardweinberger
authored andcommitted
um: Use os_warn to print out pre-boot warning/error messages
Use os_warn() instead of printf/fprintf to print out pre-boot warning/error messages to stderr. Note that the help message and version message are kept to print out to stdout, because user explicitly specifies those options to get such information. Signed-off-by: Masami Hiramatsu <[email protected]> Signed-off-by: Richard Weinberger <[email protected]>
1 parent 721ccae commit 0936d4f

File tree

8 files changed

+26
-24
lines changed

8 files changed

+26
-24
lines changed

arch/um/kernel/physmem.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ void __init setup_physmem(unsigned long start, unsigned long reserve_end,
8989
offset = uml_reserved - uml_physmem;
9090
map_size = len - offset;
9191
if(map_size <= 0) {
92-
printf("Too few physical memory! Needed=%d, given=%d\n",
93-
offset, len);
92+
os_warn("Too few physical memory! Needed=%lu, given=%lu\n",
93+
offset, len);
9494
exit(1);
9595
}
9696

@@ -99,9 +99,9 @@ void __init setup_physmem(unsigned long start, unsigned long reserve_end,
9999
err = os_map_memory((void *) uml_reserved, physmem_fd, offset,
100100
map_size, 1, 1, 1);
101101
if (err < 0) {
102-
printf("setup_physmem - mapping %ld bytes of memory at 0x%p "
103-
"failed - errno = %d\n", map_size,
104-
(void *) uml_reserved, err);
102+
os_warn("setup_physmem - mapping %ld bytes of memory at 0x%p "
103+
"failed - errno = %d\n", map_size,
104+
(void *) uml_reserved, err);
105105
exit(1);
106106
}
107107

arch/um/kernel/um_arch.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static char __initdata command_line[COMMAND_LINE_SIZE] = { 0 };
3434
static void __init add_arg(char *arg)
3535
{
3636
if (strlen(command_line) + strlen(arg) + 1 > COMMAND_LINE_SIZE) {
37-
printf("add_arg: Too many command line arguments!\n");
37+
os_warn("add_arg: Too many command line arguments!\n");
3838
exit(1);
3939
}
4040
if (strlen(command_line) > 0)
@@ -126,6 +126,7 @@ static const char *usage_string =
126126

127127
static int __init uml_version_setup(char *line, int *add)
128128
{
129+
/* Explicitly use printf() to show version in stdout */
129130
printf("%s\n", init_utsname()->release);
130131
exit(0);
131132

@@ -154,8 +155,8 @@ __uml_setup("root=", uml_root_setup,
154155

155156
static int __init no_skas_debug_setup(char *line, int *add)
156157
{
157-
printf("'debug' is not necessary to gdb UML in skas mode - run \n");
158-
printf("'gdb linux'\n");
158+
os_warn("'debug' is not necessary to gdb UML in skas mode - run\n");
159+
os_warn("'gdb linux'\n");
159160

160161
return 0;
161162
}
@@ -171,6 +172,7 @@ static int __init Usage(char *line, int *add)
171172

172173
printf(usage_string, init_utsname()->release);
173174
p = &__uml_help_start;
175+
/* Explicitly use printf() to show help in stdout */
174176
while (p < &__uml_help_end) {
175177
printf("%s", *p);
176178
p++;

arch/um/kernel/umid.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ static int __init set_umid_arg(char *name, int *add)
1616
int err;
1717

1818
if (umid_inited) {
19-
printf("umid already set\n");
19+
os_warn("umid already set\n");
2020
return 0;
2121
}
2222

2323
*add = 0;
2424
err = set_umid(name);
2525
if (err == -EEXIST)
26-
printf("umid '%s' already in use\n", name);
26+
os_warn("umid '%s' already in use\n", name);
2727
else if (!err)
2828
umid_inited = 1;
2929

arch/um/os-Linux/execvp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ int main(int argc, char**argv)
136136
int ret;
137137
argc--;
138138
if (!argc) {
139-
fprintf(stderr, "Not enough arguments\n");
139+
os_warn("Not enough arguments\n");
140140
return 1;
141141
}
142142
argv++;

arch/um/os-Linux/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ static void install_fatal_handler(int sig)
7474
action.sa_restorer = NULL;
7575
action.sa_handler = last_ditch_exit;
7676
if (sigaction(sig, &action, NULL) < 0) {
77-
printf("failed to install handler for signal %d - errno = %d\n",
78-
sig, errno);
77+
os_warn("failed to install handler for signal %d "
78+
"- errno = %d\n", sig, errno);
7979
exit(1);
8080
}
8181
}
@@ -175,7 +175,7 @@ int __init main(int argc, char **argv, char **envp)
175175
/* disable SIGIO for the fds and set SIGIO to be ignored */
176176
err = deactivate_all_fds();
177177
if (err)
178-
printf("deactivate_all_fds failed, errno = %d\n", -err);
178+
os_warn("deactivate_all_fds failed, errno = %d\n", -err);
179179

180180
/*
181181
* Let any pending signals fire now. This ensures

arch/um/os-Linux/mem.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static char * __init choose_tempdir(void)
8282

8383
dir = fallback_dir;
8484
warn:
85-
printf("Warning: tempdir %s is not on tmpfs\n", dir);
85+
os_warn("Warning: tempdir %s is not on tmpfs\n", dir);
8686
done:
8787
/* Make a copy since getenv results may not remain valid forever. */
8888
return strdup(dir);
@@ -100,7 +100,7 @@ static int __init make_tempfile(const char *template)
100100
if (tempdir == NULL) {
101101
tempdir = choose_tempdir();
102102
if (tempdir == NULL) {
103-
fprintf(stderr, "Failed to choose tempdir: %s\n",
103+
os_warn("Failed to choose tempdir: %s\n",
104104
strerror(errno));
105105
return -1;
106106
}
@@ -125,7 +125,7 @@ static int __init make_tempfile(const char *template)
125125
strcat(tempname, template);
126126
fd = mkstemp(tempname);
127127
if (fd < 0) {
128-
fprintf(stderr, "open - cannot create %s: %s\n", tempname,
128+
os_warn("open - cannot create %s: %s\n", tempname,
129129
strerror(errno));
130130
goto out;
131131
}
@@ -197,10 +197,10 @@ void __init check_tmpexec(void)
197197
os_info("Checking PROT_EXEC mmap in %s...", tempdir);
198198
if (addr == MAP_FAILED) {
199199
err = errno;
200-
printf("%s\n", strerror(err));
200+
os_warn("%s\n", strerror(err));
201201
close(fd);
202202
if (err == EPERM)
203-
printf("%s must be not mounted noexec\n", tempdir);
203+
os_warn("%s must be not mounted noexec\n", tempdir);
204204
exit(1);
205205
}
206206
os_info("OK\n");

arch/um/os-Linux/start_up.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ int __init parse_iomem(char *str, int *add)
351351
driver = str;
352352
file = strchr(str,',');
353353
if (file == NULL) {
354-
fprintf(stderr, "parse_iomem : failed to parse iomem\n");
354+
os_warn("parse_iomem : failed to parse iomem\n");
355355
goto out;
356356
}
357357
*file = '\0';

arch/um/os-Linux/umid.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ char *get_umid(void)
354354
static int __init set_uml_dir(char *name, int *add)
355355
{
356356
if (*name == '\0') {
357-
printf("uml_dir can't be an empty string\n");
357+
os_warn("uml_dir can't be an empty string\n");
358358
return 0;
359359
}
360360

@@ -365,7 +365,7 @@ static int __init set_uml_dir(char *name, int *add)
365365

366366
uml_dir = malloc(strlen(name) + 2);
367367
if (uml_dir == NULL) {
368-
printf("Failed to malloc uml_dir - error = %d\n", errno);
368+
os_warn("Failed to malloc uml_dir - error = %d\n", errno);
369369

370370
/*
371371
* Return 0 here because do_initcalls doesn't look at
@@ -390,8 +390,8 @@ static void remove_umid_dir(void)
390390
sprintf(dir, "%s%s", uml_dir, umid);
391391
err = remove_files_and_dir(dir);
392392
if (err)
393-
printf("remove_umid_dir - remove_files_and_dir failed with "
394-
"err = %d\n", err);
393+
os_warn("%s - remove_files_and_dir failed with err = %d\n",
394+
__func__, err);
395395
}
396396

397397
__uml_exitcall(remove_umid_dir);

0 commit comments

Comments
 (0)