Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752815AbdLCV7H (ORCPT ); Sun, 3 Dec 2017 16:59:07 -0500 Received: from mx02-sz.bfs.de ([194.94.69.103]:15581 "EHLO mx02-sz.bfs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752636AbdLCV7E (ORCPT ); Sun, 3 Dec 2017 16:59:04 -0500 Message-ID: <5A2473A5.2070601@bfs.de> Date: Sun, 03 Dec 2017 22:59:01 +0100 From: walter harms Reply-To: wharms@bfs.de User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.1.16) Gecko/20101125 SUSE/3.0.11 Thunderbird/3.0.11 MIME-Version: 1.0 CC: linux-kselftest@vger.kernel.org, Shuah Khan , LKML , kernel-janitors@vger.kernel.org Subject: Re: selftests: Testing a write attempt into a full file? References: <428c83c2-4752-0fe4-b135-fa23b69dca78@users.sourceforge.net> In-Reply-To: <428c83c2-4752-0fe4-b135-fa23b69dca78@users.sourceforge.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1268 Lines: 63 Am 03.12.2017 21:46, schrieb SF Markus Elfring: > Hello, > > I have constructed another demonstration program. > > > #include > #include > #include > > int main(void) > { > FILE *f = fopen("/dev/full", "a"); > > if (!f) > goto report_failure; > > { > int const c = 'X'; > > if (fputc(c, f) != c) > goto report_failure; > } > Your test is broken, you are writing actualy into a buffer. Adding setbuf(f,NULL) to disable buffering will return main: No space left on device Otherwise force the buffer to be fflush()ed and i it will also report an error. > return EXIT_SUCCESS; > > report_failure: > perror(__func__); from perror(3): errno is undefined after a successful library call so this may or may not return what you expect. re, wh > return errno; > } > > > I got the following result. > > elfring@Sonne:~/Projekte/selftests> gcc-7 putc_into_full_file1.c && ./a.out; echo $? > 0 > > > Does such a simple test example need further software development considerations? > > Regards, > Markus > -- > To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >