Hi On Wed, Sep 10, 2014 at 9:14 PM, <philippedesw...@gmail.com> wrote: > From: Philippe De Swert <philippedesw...@gmail.com> > > In test_read_one_char the filehandle does not get its fclose > at the end of the function, thus we are leaking fd's. > > Found with Coverity. Fixes: CID#1237749 > > Signed-off-by: Philippe De Swert <philippedesw...@gmail.com> > --- > src/test/test-util.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/src/test/test-util.c b/src/test/test-util.c > index 72a8a6b..0d36711 100644 > --- a/src/test/test-util.c > +++ b/src/test/test-util.c > @@ -947,6 +947,7 @@ static void test_read_one_char(void) { > assert_se(read_one_char(file, &r, 1000000, &need_nl) < 0); > > unlink(name); > + fclose(file);
This does not work. If you close "file", you also close the underlying fd. Therefore, the _cleanup_close_ on "fd" will close it again. This is fine here as we're single-threaded, but we should do it right. I fixed it up by using _cleanup_fclose_. Thanks David > } > > static void test_ignore_signals(void) { > -- > 1.8.3.2 > > _______________________________________________ > systemd-devel mailing list > systemd-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/systemd-devel _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel