Skip to content

Commit c0a9290

Browse files
congwangLinus Torvalds
authored andcommitted
uml: const and other tidying
This patch also does some improvements for uml code. Improvements include dropping unnecessary cast, killing some unnecessary code and still some constifying for pointers etc.. Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com> Signed-off-by: Jeff Dike <jdike@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 9226b83 commit c0a9290

7 files changed

Lines changed: 12 additions & 13 deletions

File tree

‎arch/um/drivers/ubd_kern.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ static int proc_ide_read_media(char *page, char **start, off_t off, int count,
229229
return len;
230230
}
231231

232-
static void make_ide_entries(char *dev_name)
232+
static void make_ide_entries(const char *dev_name)
233233
{
234234
struct proc_dir_entry *dir, *ent;
235235
char name[64];
@@ -244,7 +244,7 @@ static void make_ide_entries(char *dev_name)
244244
ent->data = NULL;
245245
ent->read_proc = proc_ide_read_media;
246246
ent->write_proc = NULL;
247-
sprintf(name,"ide0/%s", dev_name);
247+
snprintf(name, sizeof(name), "ide0/%s", dev_name);
248248
proc_symlink(dev_name, proc_ide_root, name);
249249
}
250250

@@ -443,7 +443,7 @@ __uml_help(ubd_setup,
443443
" cluster filesystem and inappropriate at almost all other times.\n\n"
444444
);
445445

446-
static int udb_setup(char *str)
446+
static int udb_setup(const char *str)
447447
{
448448
printk("udb%s specified on command line is almost certainly a ubd -> "
449449
"udb TYPO\n", str);

‎arch/um/include/kern_util.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ extern void do_uml_exitcalls(void);
8181
extern int attach_debugger(int idle_pid, int pid, int stop);
8282
extern int config_gdb(char *str);
8383
extern int remove_gdb(void);
84-
extern char *uml_strdup(char *string);
84+
extern char *uml_strdup(const char *string);
8585
extern void unprotect_kernel_mem(void);
8686
extern void protect_kernel_mem(void);
8787
extern void uml_cleanup(void);

‎arch/um/kernel/mem.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static void setup_highmem(unsigned long highmem_start,
6565
void __init mem_init(void)
6666
{
6767
/* clear the zero-page */
68-
memset((void *) empty_zero_page, 0, PAGE_SIZE);
68+
memset(empty_zero_page, 0, PAGE_SIZE);
6969

7070
/* Map in the area just after the brk now that kmalloc is about
7171
* to be turned on.

‎arch/um/kernel/process.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ unsigned long alloc_stack(int order, int atomic)
6060
if (atomic)
6161
flags = GFP_ATOMIC;
6262
page = __get_free_pages(flags, order);
63-
if (page == 0)
64-
return 0;
6563

6664
return page;
6765
}
@@ -331,7 +329,7 @@ void do_uml_exitcalls(void)
331329
(*call)();
332330
}
333331

334-
char *uml_strdup(char *string)
332+
char *uml_strdup(const char *string)
335333
{
336334
return kstrdup(string, GFP_KERNEL);
337335
}

‎arch/um/os-Linux/drivers/tuntap_user.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static int tuntap_open(void *data)
148148
memset(&ifr, 0, sizeof(ifr));
149149
ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
150150
strlcpy(ifr.ifr_name, pri->dev_name, sizeof(ifr.ifr_name));
151-
if (ioctl(pri->fd, TUNSETIFF, (void *) &ifr) < 0) {
151+
if (ioctl(pri->fd, TUNSETIFF, &ifr) < 0) {
152152
err = -errno;
153153
printk(UM_KERN_ERR "TUNSETIFF failed, errno = %d\n",
154154
errno);

‎arch/um/os-Linux/mem.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static char *tempdir = NULL;
3030

3131
static void __init find_tempdir(void)
3232
{
33-
char *dirs[] = { "TMP", "TEMP", "TMPDIR", NULL };
33+
const char *dirs[] = { "TMP", "TEMP", "TMPDIR", NULL };
3434
int i;
3535
char *dir = NULL;
3636

@@ -59,9 +59,10 @@ static void __init find_tempdir(void)
5959
* read the file as needed. If there's an error, -errno is returned;
6060
* if the end of the file is reached, 0 is returned.
6161
*/
62-
static int next(int fd, char *buf, int size, char c)
62+
static int next(int fd, char *buf, size_t size, char c)
6363
{
64-
int n, len;
64+
ssize_t n;
65+
size_t len;
6566
char *ptr;
6667

6768
while((ptr = strchr(buf, c)) == NULL){

‎arch/um/os-Linux/sigio.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ static int async_pty(int master, int slave)
407407
if((fcntl(slave, F_SETFL, flags | O_NONBLOCK) < 0))
408408
return -errno;
409409

410-
return(0);
410+
return 0;
411411
}
412412

413413
static void __init check_one_sigio(void (*proc)(int, int))

0 commit comments

Comments
 (0)