Re: [PATCH kvmtool 14/16] Factor epoll thread

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 21, 2023 at 06:11:29PM +0100, Andre Przywara wrote:
> > +	read(epoll->stop_fd, &stop, sizeof(stop));
> > +	write(epoll->stop_fd, &stop, sizeof(stop));
> 
> read(2) and write(2) (sys)calls without checking the return value upsets
> Ubuntu's compiler:
> 
> epoll.c: In function ‘epoll__thread’:
> epoll.c:27:2: error: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Werror=unused-result]
>    27 |  read(epoll->stop_fd, &stop, sizeof(stop));
>       |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> (same for the write in the line after)
> Since we use -Werror, this is fatal.
> 
> I fixed it for now with:
> 	if (read(epoll->stop_fd, &stop, sizeof(stop)) < 0)
> 		return NULL;
> 
> Not sure if there is a more meaningful way to bail out at this point.

Ah right, previous code did `tmp = write(fd, &tmp, sizeof(tmp))` which
seemed too silly to keep, and my compilers didn't complain. I'll add
pr_warnings here.

Thanks,
Jean




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux