[PATCH 14/24] fread.3: Move ARRAY_SIZE logic into macro

Alejandro Colomar
2020-09-10T21:17:30Z

Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
---
man3/fread.3 | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/man3/fread.3 b/man3/fread.3
index 4c5dc3dbc..8e71e620e 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);
--
2.28.0