[PATCH] uml: remove NULL checks and add some CodingStyle
Remove redundant NULL checks before [kv]free + small CodingStyle cleanup for arch/ Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com> Signed-off-by: Jeff Dike <jdike@addtoit.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
893bb96a29
commit
191ef966ac
|
@ -89,7 +89,9 @@ void sigio_handler(int sig, union uml_pt_regs *regs)
|
|||
struct irq_fd *irq_fd;
|
||||
int n;
|
||||
|
||||
if(smp_sigio_handler()) return;
|
||||
if (smp_sigio_handler())
|
||||
return;
|
||||
|
||||
while (1) {
|
||||
n = os_waiting_for_events(active_fds);
|
||||
if (n <= 0) {
|
||||
|
@ -114,15 +116,13 @@ static void maybe_sigio_broken(int fd, int type)
|
|||
if ((type == IRQ_WRITE) && !pty_output_sigio) {
|
||||
write_sigio_workaround();
|
||||
add_sigio_fd(fd, 0);
|
||||
}
|
||||
else if((type == IRQ_READ) && !pty_close_sigio){
|
||||
} else if ((type == IRQ_READ) && !pty_close_sigio) {
|
||||
write_sigio_workaround();
|
||||
add_sigio_fd(fd, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int activate_fd(int irq, int fd, int type, void *dev_id)
|
||||
{
|
||||
struct pollfd *tmp_pfd;
|
||||
|
@ -140,8 +140,10 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
|
|||
if (new_fd == NULL)
|
||||
goto out;
|
||||
|
||||
if(type == IRQ_READ) events = UM_POLLIN | UM_POLLPRI;
|
||||
else events = UM_POLLOUT;
|
||||
if (type == IRQ_READ)
|
||||
events = UM_POLLIN | UM_POLLPRI;
|
||||
else
|
||||
events = UM_POLLOUT;
|
||||
*new_fd = ((struct irq_fd) { .next = NULL,
|
||||
.id = dev_id,
|
||||
.fd = fd,
|
||||
|
@ -198,10 +200,8 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
|
|||
* then we free the buffer tmp_fds and try again.
|
||||
*/
|
||||
irq_unlock(flags);
|
||||
if (tmp_pfd != NULL) {
|
||||
kfree(tmp_pfd);
|
||||
tmp_pfd = NULL;
|
||||
}
|
||||
|
||||
tmp_pfd = um_kmalloc(n);
|
||||
if (tmp_pfd == NULL)
|
||||
|
@ -277,7 +277,8 @@ static struct irq_fd *find_irq_by_fd(int fd, int irqnum, int *index_out)
|
|||
int fdi;
|
||||
|
||||
for (irq = active_fds; irq != NULL; irq = irq->next) {
|
||||
if((irq->fd == fd) && (irq->irq == irqnum)) break;
|
||||
if ((irq->fd == fd) && (irq->irq == irqnum))
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
if (irq == NULL) {
|
||||
|
@ -294,7 +295,7 @@ static struct irq_fd *find_irq_by_fd(int fd, int irqnum, int *index_out)
|
|||
}
|
||||
*index_out = i;
|
||||
out:
|
||||
return(irq);
|
||||
return irq;
|
||||
}
|
||||
|
||||
void reactivate_fd(int fd, int irqnum)
|
||||
|
@ -341,12 +342,12 @@ int deactivate_all_fds(void)
|
|||
for (irq = active_fds; irq != NULL; irq = irq->next) {
|
||||
err = os_clear_fd_async(irq->fd);
|
||||
if (err)
|
||||
return(err);
|
||||
return err;
|
||||
}
|
||||
/* If there is a signal already queued, after unblocking ignore it */
|
||||
os_set_ioignore();
|
||||
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void forward_interrupts(int pid)
|
||||
|
@ -393,11 +394,11 @@ int um_request_irq(unsigned int irq, int fd, int type,
|
|||
|
||||
err = request_irq(irq, handler, irqflags, devname, dev_id);
|
||||
if (err)
|
||||
return(err);
|
||||
return err;
|
||||
|
||||
if (fd != -1)
|
||||
err = activate_fd(irq, fd, type, dev_id);
|
||||
return(err);
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL(um_request_irq);
|
||||
EXPORT_SYMBOL(reactivate_fd);
|
||||
|
@ -409,7 +410,7 @@ unsigned long irq_lock(void)
|
|||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&irq_spinlock, flags);
|
||||
return(flags);
|
||||
return flags;
|
||||
}
|
||||
|
||||
void irq_unlock(unsigned long flags)
|
||||
|
@ -488,5 +489,5 @@ int init_aio_irq(int irq, char *name, irqreturn_t (*handler)(int, void *,
|
|||
os_close_file(fds[0]);
|
||||
os_close_file(fds[1]);
|
||||
out:
|
||||
return(err);
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ int os_waiting_for_events(struct irq_fd *active_fds)
|
|||
|
||||
int os_isatty(int fd)
|
||||
{
|
||||
return(isatty(fd));
|
||||
return isatty(fd);
|
||||
}
|
||||
|
||||
int os_create_pollfd(int fd, int events, void *tmp_pfd, int size_tmpfds)
|
||||
|
@ -73,18 +73,15 @@ int os_create_pollfd(int fd, int events, void *tmp_pfd, int size_tmpfds)
|
|||
}
|
||||
pollfds = tmp_pfd;
|
||||
pollfds_size++;
|
||||
} else {
|
||||
/* remove not used tmp_pfd */
|
||||
if (tmp_pfd != NULL)
|
||||
kfree(tmp_pfd);
|
||||
}
|
||||
} else
|
||||
kfree(tmp_pfd); /* remove not used tmp_pfd */
|
||||
|
||||
pollfds[pollfds_num] = ((struct pollfd) { .fd = fd,
|
||||
.events = events,
|
||||
.revents = 0 });
|
||||
pollfds_num++;
|
||||
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void os_free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg,
|
||||
|
@ -110,7 +107,6 @@ void os_free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg,
|
|||
/* This moves the *whole* array after pollfds[i]
|
||||
* (though it doesn't spot as such)!
|
||||
*/
|
||||
|
||||
memmove(&pollfds[i], &pollfds[i + 1],
|
||||
(pollfds_num - i) * sizeof(pollfds[0]));
|
||||
if(*last_irq_ptr2 == &old_fd->next)
|
||||
|
@ -129,10 +125,9 @@ void os_free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg,
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
int os_get_pollfd(int i)
|
||||
{
|
||||
return(pollfds[i].fd);
|
||||
return pollfds[i].fd;
|
||||
}
|
||||
|
||||
void os_set_pollfd(int i, int fd)
|
||||
|
@ -151,8 +146,10 @@ void init_irq_signals(int on_sigstack)
|
|||
int flags;
|
||||
|
||||
flags = on_sigstack ? SA_ONSTACK : 0;
|
||||
if(timer_irq_inited) h = (__sighandler_t) alarm_handler;
|
||||
else h = boot_timer_handler;
|
||||
if (timer_irq_inited)
|
||||
h = (__sighandler_t)alarm_handler;
|
||||
else
|
||||
h = boot_timer_handler;
|
||||
|
||||
set_handler(SIGVTALRM, h, flags | SA_RESTART,
|
||||
SIGUSR1, SIGIO, SIGWINCH, SIGALRM, -1);
|
||||
|
|
Loading…
Reference in New Issue