UML - umid cleanup
PATCH 2/9 UML - umid cleanup
This patch cleans up the umid code:
The only_if_set argument to get_umid is gone. get_umid returns an empty string rather than NULL if there is
no umid.
umid_is_random is gone since its users went away. Some printfs were turned into printks because the code runs
late enough that printk is working.
Error paths were cleaned up.
Some functions now return an error and let the caller print
the error message rather than printing it themselves. This eliminates the practice of passing a pointer to printf or printk in, depending on where in the boot process we are.
Major tidying of not_dead_yet - mostly error path cleanup,
plus a comment explaining why it doesn't react to errors the way you might expect.
Calls to os_* interfaces that were moved under os are changed
back to their native libc forms.
snprintf, strlcpy, and their bounds-checking friends are used
more often, replacing by-hand bounds checking in some places.
arch/um/drivers/line.c +2 -2
@@ -831,8 +831,8 @@ char *add_xterm_umid(char *base)char *umid, *title;int len; - umid =get_umid (1 ); -if (umid ==NULL ) + umid =get_umid (); +if (*umid =='\0' )return base; len =strlen (base) +strlen (" ()" ) +strlen (umid) +1 ;
arch/um/include/os.h +2 -2
@@ -216,7 +216,7 @@ extern int helper_wait(int pid);/* umid.c */ extern int umid_file_name (char *name,char *buf,int len); -extern int set_umid (char *name,int (*printer)(const char *fmt, ...)); -extern char *get_umid (int only_if_set); +extern int set_umid (char *name); +extern char *get_umid (void );#endif
arch/um/include/user_util.h +0 -1
@@ -64,7 +64,6 @@ extern void setup_machinename(char *machextern void setup_hostinfo (void );extern void do_exec (int old_pid,int new_pid);extern void tracer_panic (char *msg, ...); -extern char *get_umid (int only_if_set);extern void do_longjmp (void *p,int val);extern int detach (int pid,int sig);extern int attach (int pid);
arch/um/kernel/um_arch.c +2 -2
@@ -146,8 +146,8 @@ void set_cmdline(char *cmd)if (CHOOSE_MODE (honeypot,0 ))return ; - umid =get_umid (1 ); -if (umid !=NULL ){ + umid =get_umid (); +if (*umid !='\0' ){snprintf (argv1_begin, (argv1_end - argv1_begin) *sizeof (*ptr),"(%s) " , umid);
arch/um/kernel/umid.c +4 -8
@@ -3,15 +3,13 @@* Licensed under the GPL */ -#include "linux/stddef.h" -#include "linux/kernel.h" #include "asm/errno.h" #include "init.h" #include "os.h" #include "kern.h" +#include "linux/kernel.h" -/* Changed by set_umid_arg and umid_file_name */ -int umid_is_random =0 ; +/* Changed by set_umid_arg */ static int umid_inited =0 ;static int __init set_umid_arg (char *name,int *add)
@@ -22,11 +20,9 @@ static int __init set_umid_arg(char *namreturn 0 ; *add =0 ; - err =set_umid (name, printf); -if (err == -EEXIST ){ + err =set_umid (name); +if (err == -EEXIST )printf ("umid '%s' already in use\n" , name); - umid_is_random =1 ; - }else if (!err) umid_inited =1 ;
arch/um/os-Linux/umid.c +157 -114
412 lines not on this page · raw message
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel