poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 1/2] pkl: Add user_data in IO device API


From: Jose E. Marchesi
Subject: Re: [PATCH v2 1/2] pkl: Add user_data in IO device API
Date: Thu, 23 Dec 2021 11:05:12 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi Mohammad.
Thanks for the patch.

>  static void *
> -ios_dev_file_open (const char *handler, uint64_t flags, int *error)
> +ios_dev_file_open (const char *handler, uint64_t flags, int *error, void 
> *data)
>  {
>    struct ios_dev_file *fio = NULL;
>    FILE *f = NULL;
> @@ -107,6 +107,8 @@ ios_dev_file_open (const char *handler, uint64_t flags, 
> int *error)
>    int flags_for_open = 0;
>    int fd;
>  
> +  (void)data;
> +
>    if (mode_flags != 0)
>      {
>        /* Decide what mode to use to open the file.  */

(And in other similar places.)

Please use __attribute__((unused)) to avoid warnings for arguments that
are not used.

> diff --git a/libpoke/ios-dev.h b/libpoke/ios-dev.h
> index 2ffd5fea..a296ce29 100644
> --- a/libpoke/ios-dev.h
> +++ b/libpoke/ios-dev.h
> @@ -65,9 +65,10 @@ struct ios_dev_if
>    /* Open a device using the provided HANDLER.  Return the opened
>       device, or NULL in case of errors.  Set the ERROR to error code or to
>       IOD_OK.  Note that this function assumes that HANDLER is recognized as a
> -     handler by the backend.  */
> +     handler by the backend.  USER_DATA is the user-provided data.  */
>  
> -  void * (*open) (const char *handler, uint64_t flags, int *error);
> +  void * (*open) (const char *handler, uint64_t flags, int *error,
> +                  void *user_data);
>  
>    /* Close the given device.  Return the error code if there was an error
>       during the operation, IOD_OK otherwise.  */

I think `USER_DATA is the user-provided data.' is not very helpful as a
doc string :)

What about something like this: "USER_DATA is the `user_data' pointer
below, intended to be used as an IOD-specific payload."

> @@ -94,9 +95,13 @@ struct ios_dev_if
>  
>    /* If called on a in-stream, free the buffer before OFFSET.  If called on
>       an out-stream, flush the data till OFFSET and free the buffer before
> -     OFFSET.  Otherwise, do not do anything.  Return IOS_OK ın success and
> +     OFFSET.  Otherwise, do not do anything.  Return IOS_OK in success and
>       an error code on failure.  */
>    int (*flush) (void *dev, ios_dev_off offset);
> +
> +  /* User data that will be passed to OPEN function.  */
> +
> +  void *user_data;
>  };

No need for an empty line between the comment and the field.  You could
state in the doc string that the pointer is initialized to NULL.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]