From: walter harms <wharms@bfs.de>
To: kernel-janitors@vger.kernel.org
Subject: Re: selftests: Testing a write attempt into a full file?
Date: Sun, 03 Dec 2017 21:59:01 +0000 [thread overview]
Message-ID: <5A2473A5.2070601@bfs.de> (raw)
In-Reply-To: <428c83c2-4752-0fe4-b135-fa23b69dca78@users.sourceforge.net>
Am 03.12.2017 21:46, schrieb SF Markus Elfring:
> Hello,
>
> I have constructed another demonstration program.
>
>
> #include <errno.h>
> #include <stdio.h>
> #include <stdlib.h>
>
> 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
>
WARNING: multiple messages have this Message-ID (diff)
From: wharms at bfs.de (walter harms)
Subject: [Linux-kselftest-mirror] selftests: Testing a write attempt into a full file?
Date: Sun, 03 Dec 2017 22:59:01 +0100 [thread overview]
Message-ID: <5A2473A5.2070601@bfs.de> (raw)
In-Reply-To: <428c83c2-4752-0fe4-b135-fa23b69dca78@users.sourceforge.net>
Am 03.12.2017 21:46, schrieb SF Markus Elfring:
> Hello,
>
> I have constructed another demonstration program.
>
>
> #include <errno.h>
> #include <stdio.h>
> #include <stdlib.h>
>
> 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 at 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 at vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: wharms@bfs.de (walter harms)
Subject: [Linux-kselftest-mirror] selftests: Testing a write attempt into a full file?
Date: Sun, 03 Dec 2017 22:59:01 +0100 [thread overview]
Message-ID: <5A2473A5.2070601@bfs.de> (raw)
Message-ID: <20171203215901.WoH7q7YQVd5iKASuU3RmgYtF6qfn_ECA1W-vTX5V2qo@z> (raw)
In-Reply-To: <428c83c2-4752-0fe4-b135-fa23b69dca78@users.sourceforge.net>
Am 03.12.2017 21:46, schrieb SF Markus Elfring:
> Hello,
>
> I have constructed another demonstration program.
>
>
> #include <errno.h>
> #include <stdio.h>
> #include <stdlib.h>
>
> 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 at 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 at vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: walter harms <wharms@bfs.de>
To: unlisted-recipients:; (no To-header on input)
Cc: linux-kselftest@vger.kernel.org, Shuah Khan <shuah@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org
Subject: Re: selftests: Testing a write attempt into a full file?
Date: Sun, 03 Dec 2017 22:59:01 +0100 [thread overview]
Message-ID: <5A2473A5.2070601@bfs.de> (raw)
In-Reply-To: <428c83c2-4752-0fe4-b135-fa23b69dca78@users.sourceforge.net>
Am 03.12.2017 21:46, schrieb SF Markus Elfring:
> Hello,
>
> I have constructed another demonstration program.
>
>
> #include <errno.h>
> #include <stdio.h>
> #include <stdlib.h>
>
> 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
>
next prev parent reply other threads:[~2017-12-03 21:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-03 20:46 selftests: Testing a write attempt into a full file? SF Markus Elfring
2017-12-03 20:46 ` SF Markus Elfring
2017-12-03 20:46 ` [Linux-kselftest-mirror] " SF Markus Elfring
2017-12-03 20:46 ` elfring
2017-12-03 21:59 ` walter harms [this message]
2017-12-03 21:59 ` walter harms
2017-12-03 21:59 ` [Linux-kselftest-mirror] " walter harms
2017-12-03 21:59 ` wharms
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5A2473A5.2070601@bfs.de \
--to=wharms@bfs.de \
--cc=kernel-janitors@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.