[PATCH 09/13] virnetclient: Update comment about memset()

Michal Privoznik posted 13 patches 2 years, 6 months ago
[PATCH 09/13] virnetclient: Update comment about memset()
Posted by Michal Privoznik 2 years, 6 months ago
Instead of suggesting to zero structs out using memset() we
should suggest initializing structs with zero initializer.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/rpc/virnetclient.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index df2958935b..18f87653f5 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -1857,8 +1857,8 @@ static void virNetClientIOUpdateCallback(virNetClient *client,
  * which come from the user).  It does however free any intermediate
  * results, eg. the error structure if there is one.
  *
- * NB(2). Make sure to memset (&ret, 0, sizeof(ret)) before calling,
- * else Bad Things will happen in the XDR code.
+ * NB(2). Make sure to initialize ret variable to { 0 } before calling,
+ * else Bad things will happen in the XDR code.
  *
  * NB(3) You must have the client lock before calling this
  *
-- 
2.41.0
Re: [PATCH 09/13] virnetclient: Update comment about memset()
Posted by Claudio Fontana 2 years, 6 months ago
On 8/3/23 12:36, Michal Privoznik wrote:
> Instead of suggesting to zero structs out using memset() we
> should suggest initializing structs with zero initializer.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

Reviewed-by: Claudio Fontana <cfontana@suse.de>

> ---
>  src/rpc/virnetclient.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
> index df2958935b..18f87653f5 100644
> --- a/src/rpc/virnetclient.c
> +++ b/src/rpc/virnetclient.c
> @@ -1857,8 +1857,8 @@ static void virNetClientIOUpdateCallback(virNetClient *client,
>   * which come from the user).  It does however free any intermediate
>   * results, eg. the error structure if there is one.
>   *
> - * NB(2). Make sure to memset (&ret, 0, sizeof(ret)) before calling,
> - * else Bad Things will happen in the XDR code.
> + * NB(2). Make sure to initialize ret variable to { 0 } before calling,
> + * else Bad things will happen in the XDR code.
>   *
>   * NB(3) You must have the client lock before calling this
>   *