lkml.org 
[lkml]   [2020]   [Sep]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 14/24] fread.3: Move ARRAY_SIZE logic into macro
Date
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
\
 
 \ /
  Last update: 2020-09-10 23:18    [W:0.417 / U:0.332 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site