Re: Kevent POSIX timers support.

Tushar Adeshara
2006-12-13T13:21:50Z

On 11/23/06, Evgeniy Polyakov <johnpol@2ka.mipt.ru> wrote:
> On Wed, Nov 22, 2006 at 01:44:16PM +0300, Evgeniy Polyakov (johnpol@2ka.mipt.ru) wrote:
> +static int posix_kevent_init_timer(struct k_itimer *tmr, int fd)
> +{
> + struct ukevent uk;
> + struct file *file;
> + struct kevent_user *u;
> + int err;
> +
> + file = fget(fd);
> + if (!file) {
> + err = -EBADF;
> + goto err_out;
> + }
> +
> + if (file->f_op != &kevent_user_fops) {
> + err = -EINVAL;
> + goto err_out_fput;
> + }
> +
> + u = file->private_data;
> +
> + memset(&uk, 0, sizeof(struct ukevent));
> +
> + uk.type = KEVENT_POSIX_TIMER;
> + uk.id.raw_u64 = (unsigned long)(tmr); /* Just cast to something unique */
> + uk.ptr = tmr;
> +
> + tmr->it_sigev_value.sival_ptr = file;
> +
> + err = kevent_user_add_ukevent(&uk, u);

I think these four lines are not required. Irrespective of return
value of kevent_user_add_ukevent(), we are going to release file, and
return err.

> + if (err)
> + goto err_out_fput;
> +
> + fput(file);
> +
> + return 0;

> +
> +err_out_fput:
> + fput(file);
> +err_out:
> + return err;
> +}
> +

--
Regards,
Tushar
--------------------
It's not a problem, it's an opportunity for improvement. Lets improve.