All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fanotify.3: Pass array to read(2) directly instead of a pointer to it
@ 2020-09-05 11:28 Alejandro Colomar
  2020-09-05 11:42 ` Alejandro Colomar
  0 siblings, 1 reply; 3+ messages in thread
From: Alejandro Colomar @ 2020-09-05 11:28 UTC (permalink / raw)
  To: mtk.manpages; +Cc: linux-man, Alejandro Colomar

It doesn't make any sense to pass a pointer to the array to read(2).

It might make sense to pass a pointer to the first element of the array,
but that is already implicitly done when passing the array, which decays
to that pointer, so it's simpler to pass the array.

And anyway, the cast was unneeded, as any pointer is implicitly casted
to `void *`.

Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
---
 man7/fanotify.7 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/man7/fanotify.7 b/man7/fanotify.7
index c18ab68ed..c3d40b56d 100644
--- a/man7/fanotify.7
+++ b/man7/fanotify.7
@@ -818,7 +818,7 @@ handle_events(int fd)
 
         /* Read some events */
 
-        len = read(fd, (void *) &buf, sizeof(buf));
+        len = read(fd, buf, sizeof(buf));
         if (len == \-1 && errno != EAGAIN) {
             perror("read");
             exit(EXIT_FAILURE);
@@ -1111,7 +1111,7 @@ main(int argc, char **argv)
 
     /* Read events from the event queue into a buffer */
 
-    len = read(fd, (void *) &events_buf, sizeof(events_buf));
+    len = read(fd, events_buf, sizeof(events_buf));
     if (len == \-1 && errno != EAGAIN) {
         perror("read");
         exit(EXIT_FAILURE);
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] fanotify.3: Pass array to read(2) directly instead of a pointer to it
  2020-09-05 11:28 [PATCH] fanotify.3: Pass array to read(2) directly instead of a pointer to it Alejandro Colomar
@ 2020-09-05 11:42 ` Alejandro Colomar
  2020-09-05 15:44   ` Michael Kerrisk (man-pages)
  0 siblings, 1 reply; 3+ messages in thread
From: Alejandro Colomar @ 2020-09-05 11:42 UTC (permalink / raw)
  To: mtk.manpages; +Cc: linux-man

Hi Michael,

I had a typo in the subject.  It's fanotify.7; please fix it when
applying the patch.

Cheers,
Alex

On 9/5/20 1:28 PM, Alejandro Colomar wrote:
> It doesn't make any sense to pass a pointer to the array to read(2).
> 
> It might make sense to pass a pointer to the first element of the array,
> but that is already implicitly done when passing the array, which decays
> to that pointer, so it's simpler to pass the array.
> 
> And anyway, the cast was unneeded, as any pointer is implicitly casted
> to `void *`.
> 
> Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
> ---
>  man7/fanotify.7 | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/man7/fanotify.7 b/man7/fanotify.7
> index c18ab68ed..c3d40b56d 100644
> --- a/man7/fanotify.7
> +++ b/man7/fanotify.7
> @@ -818,7 +818,7 @@ handle_events(int fd)
>  
>          /* Read some events */
>  
> -        len = read(fd, (void *) &buf, sizeof(buf));
> +        len = read(fd, buf, sizeof(buf));
>          if (len == \-1 && errno != EAGAIN) {
>              perror("read");
>              exit(EXIT_FAILURE);
> @@ -1111,7 +1111,7 @@ main(int argc, char **argv)
>  
>      /* Read events from the event queue into a buffer */
>  
> -    len = read(fd, (void *) &events_buf, sizeof(events_buf));
> +    len = read(fd, events_buf, sizeof(events_buf));
>      if (len == \-1 && errno != EAGAIN) {
>          perror("read");
>          exit(EXIT_FAILURE);
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fanotify.3: Pass array to read(2) directly instead of a pointer to it
  2020-09-05 11:42 ` Alejandro Colomar
@ 2020-09-05 15:44   ` Michael Kerrisk (man-pages)
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-09-05 15:44 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: mtk.manpages, linux-man

On 9/5/20 1:42 PM, Alejandro Colomar wrote:
> Hi Michael,
> 
> I had a typo in the subject.  It's fanotify.7; please fix it when
> applying the patch.

Patch applied. and title line fixed.

Thanks, Alex.

Cheers,

Michael

> On 9/5/20 1:28 PM, Alejandro Colomar wrote:
>> It doesn't make any sense to pass a pointer to the array to read(2).
>>
>> It might make sense to pass a pointer to the first element of the array,
>> but that is already implicitly done when passing the array, which decays
>> to that pointer, so it's simpler to pass the array.
>>
>> And anyway, the cast was unneeded, as any pointer is implicitly casted
>> to `void *`.
>>
>> Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
>> ---
>>  man7/fanotify.7 | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/man7/fanotify.7 b/man7/fanotify.7
>> index c18ab68ed..c3d40b56d 100644
>> --- a/man7/fanotify.7
>> +++ b/man7/fanotify.7
>> @@ -818,7 +818,7 @@ handle_events(int fd)
>>  
>>          /* Read some events */
>>  
>> -        len = read(fd, (void *) &buf, sizeof(buf));
>> +        len = read(fd, buf, sizeof(buf));
>>          if (len == \-1 && errno != EAGAIN) {
>>              perror("read");
>>              exit(EXIT_FAILURE);
>> @@ -1111,7 +1111,7 @@ main(int argc, char **argv)
>>  
>>      /* Read events from the event queue into a buffer */
>>  
>> -    len = read(fd, (void *) &events_buf, sizeof(events_buf));
>> +    len = read(fd, events_buf, sizeof(events_buf));
>>      if (len == \-1 && errno != EAGAIN) {
>>          perror("read");
>>          exit(EXIT_FAILURE);
>>


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-05 15:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-05 11:28 [PATCH] fanotify.3: Pass array to read(2) directly instead of a pointer to it Alejandro Colomar
2020-09-05 11:42 ` Alejandro Colomar
2020-09-05 15:44   ` Michael Kerrisk (man-pages)

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.