[Spice-devel] [PATCH 2/2] Remove all usages of bzero()

Alon Levy alevy at redhat.com
Tue Feb 14 08:18:07 PST 2012


On Tue, Feb 14, 2012 at 09:57:55AM -0600, Dan McGee wrote:
> As recommended by modern C practice, we should just be using memset().

Sorry for the lack of knowledge, but can you point to the
recommendation?

> 
> Signed-off-by: Dan McGee <dpmcgee at gmail.com>
> ---
>  server/tests/basic_event_loop.c   |    2 +-
>  server/tests/test_display_base.c  |    6 +++---
>  server/tests/test_empty_success.c |    4 ++--
>  3 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/server/tests/basic_event_loop.c b/server/tests/basic_event_loop.c
> index c0ee705..70eb026 100644
> --- a/server/tests/basic_event_loop.c
> +++ b/server/tests/basic_event_loop.c
> @@ -267,7 +267,7 @@ SpiceCoreInterface *basic_event_loop_init(void)
>  {
>      ring_init(&watches);
>      ring_init(&timers);
> -    bzero(&core, sizeof(core));
> +    memset(&core, 0, sizeof(core));
>      core.base.major_version = SPICE_INTERFACE_CORE_MAJOR;
>      core.base.minor_version = SPICE_INTERFACE_CORE_MINOR; // anything less then 3 and channel_event isn't called
>      core.timer_add = timer_add;
> diff --git a/server/tests/test_display_base.c b/server/tests/test_display_base.c
> index 811e901..63cbf2f 100644
> --- a/server/tests/test_display_base.c
> +++ b/server/tests/test_display_base.c
> @@ -339,7 +339,7 @@ static void set_mm_time(QXLInstance *qin, uint32_t mm_time)
>  
>  static void get_init_info(QXLInstance *qin, QXLDevInitInfo *info)
>  {
> -    bzero(info, sizeof(*info));
> +    memset(info, 0, sizeof(*info));
>      info->num_memslots = 1;
>      info->num_memslots_groups = 1;
>      info->memslot_id_bits = 1;
> @@ -644,8 +644,8 @@ SpiceServer* test_init(SpiceCoreInterface *core)
>      spice_server_init(server, core);
>  
>      path_init(&path, 0, angle_parts);
> -    bzero(primary_surface, sizeof(primary_surface));
> -    bzero(secondary_surface, sizeof(secondary_surface));
> +    memset(primary_surface, 0, sizeof(primary_surface));
> +    memset(secondary_surface, 0, sizeof(secondary_surface));
>      has_secondary = 0;
>      wakeup_timer = core->timer_add(do_wakeup, NULL);
>      return server;
> diff --git a/server/tests/test_empty_success.c b/server/tests/test_empty_success.c
> index 435efbf..ccabe6b 100644
> --- a/server/tests/test_empty_success.c
> +++ b/server/tests/test_empty_success.c
> @@ -1,6 +1,6 @@
>  #include <config.h>
>  #include <stdlib.h>
> -#include <strings.h>
> +#include <string.h>
>  
>  #include <spice.h>
>  
> @@ -43,7 +43,7 @@ int main(void)
>      SpiceServer *server = spice_server_new();
>      SpiceCoreInterface core;
>  
> -    bzero(&core, sizeof(core));
> +    memset(&core, 0, sizeof(core));
>      core.base.major_version = SPICE_INTERFACE_CORE_MAJOR;
>      core.timer_add = timer_add;
>      core.timer_start = timer_start;
> -- 
> 1.7.9
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel


More information about the Spice-devel mailing list