diff options
| author | Alejandro Colomar <colomar.6.4.3@gmail.com> | 2020-09-10 23:13:35 +0200 |
|---|---|---|
| committer | Michael Kerrisk <mtk.manpages@gmail.com> | 2020-09-11 11:33:28 +0200 |
| commit | cbb22338cf4c68d427c7d65c9d61e1a3be9388ff (patch) | |
| tree | dabe41fbe2e8f4130f5ab5e18b3d513632604df6 | |
| parent | 3996bc9c26878b6b7288b6737b887aa6b8533470 (diff) | |
| download | man-pages-cbb22338cf4c68d427c7d65c9d61e1a3be9388ff.tar.gz | |
fread.3: Move ARRAY_SIZE logic into macro
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
| -rw-r--r-- | man3/fread.3 | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/man3/fread.3 b/man3/fread.3 index 4c5dc3dbc0..8e71e620e0 100644 --- a/man3/fread.3 +++ b/man3/fread.3 @@ -136,6 +136,8 @@ Class: 0x02 #include <stdio.h> #include <stdlib.h> +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) + int main(void) { @@ -147,9 +149,7 @@ main(void) unsigned char buffer[4]; - size_t ret = - fread(buffer, sizeof(buffer) / sizeof(*buffer), sizeof(*buffer), - fp); + size_t ret = fread(buffer, ARRAY_SIZE(buffer), sizeof(*buffer), fp); if (ret != sizeof(*buffer)) { fprintf(stderr, "fread() failed: %zu\en", ret); exit(EXIT_FAILURE); |
