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

[Xen-changelog] [xen-unstable] tools: Fix memset(&p, 0, sizeof(p)) idiom in several places.


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Thu, 14 Feb 2013 19:44:09 +0000
  • Delivery-date: Thu, 14 Feb 2013 19:44:20 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Michael Young <m.a.young@xxxxxxxxxxxx>
# Date 1360774815 0
# Node ID 742dde457258422a3d08e3ddbf9a7eae55c93acb
# Parent  63594ce1708ffb1269cd124c3a864485eeba1736
tools: Fix memset(&p,0,sizeof(p)) idiom in several places.

gcc 4.8 identifies several places where code of the form memset(x, 0,
sizeof(x)); is used incorrectly, meaning that less memory is set to
zero than required.

Signed-off-by: Michael Young <m.a.young@xxxxxxxxxxxx>
Committed-by: Keir Fraser <keir@xxxxxxx>
---


diff -r 63594ce1708f -r 742dde457258 tools/blktap2/drivers/md5.c
--- a/tools/blktap2/drivers/md5.c       Wed Feb 13 09:31:48 2013 +0100
+++ b/tools/blktap2/drivers/md5.c       Wed Feb 13 17:00:15 2013 +0000
@@ -174,7 +174,7 @@ void MD5Final(unsigned char digest[16], 
     MD5Transform(ctx->buf, (uint32_t *) ctx->in);
     byteReverse((unsigned char *) ctx->buf, 4);
     memcpy(digest, ctx->buf, 16);
-    memset(ctx, 0, sizeof(ctx));     /* In case it's sensitive */
+    memset(ctx, 0, sizeof(*ctx));     /* In case it's sensitive */
 }
 
 /* The four core functions - F1 is optimized somewhat */
diff -r 63594ce1708f -r 742dde457258 tools/debugger/kdd/kdd-xen.c
--- a/tools/debugger/kdd/kdd-xen.c      Wed Feb 13 09:31:48 2013 +0100
+++ b/tools/debugger/kdd/kdd-xen.c      Wed Feb 13 17:00:15 2013 +0000
@@ -333,7 +333,7 @@ int kdd_get_regs(kdd_guest *g, int cpuid
     if (!cpu) 
         return -1;
 
-    memset(r, 0, sizeof(r));
+    memset(r, 0, sizeof(*r));
     
     if (w64)
         kdd_get_regs_x86_64(cpu, &r->r64);
diff -r 63594ce1708f -r 742dde457258 tools/libxc/xc_dom_boot.c
--- a/tools/libxc/xc_dom_boot.c Wed Feb 13 09:31:48 2013 +0100
+++ b/tools/libxc/xc_dom_boot.c Wed Feb 13 17:00:15 2013 +0000
@@ -266,7 +266,7 @@ int xc_dom_boot_image(struct xc_dom_imag
         return rc;
 
     /* let the vm run */
-    memset(ctxt, 0, sizeof(ctxt));
+    memset(ctxt, 0, sizeof(*ctxt));
     if ( (rc = dom->arch_hooks->vcpu(dom, ctxt)) != 0 )
         return rc;
     xc_dom_unmap_all(dom);
diff -r 63594ce1708f -r 742dde457258 tools/libxl/libxl_qmp.c
--- a/tools/libxl/libxl_qmp.c   Wed Feb 13 09:31:48 2013 +0100
+++ b/tools/libxl/libxl_qmp.c   Wed Feb 13 17:00:15 2013 +0000
@@ -378,7 +378,7 @@ static int qmp_open(libxl__qmp_handler *
     ret = libxl_fd_set_cloexec(qmp->ctx, qmp->qmp_fd, 1);
     if (ret) return -1;
 
-    memset(&qmp->addr, 0, sizeof (&qmp->addr));
+    memset(&qmp->addr, 0, sizeof (qmp->addr));
     qmp->addr.sun_family = AF_UNIX;
     strncpy(qmp->addr.sun_path, qmp_socket_path,
             sizeof (qmp->addr.sun_path));
diff -r 63594ce1708f -r 742dde457258 
tools/python/xen/lowlevel/netlink/libnetlink.c
--- a/tools/python/xen/lowlevel/netlink/libnetlink.c    Wed Feb 13 09:31:48 
2013 +0100
+++ b/tools/python/xen/lowlevel/netlink/libnetlink.c    Wed Feb 13 17:00:15 
2013 +0000
@@ -37,7 +37,7 @@ int rtnl_open_byproto(struct rtnl_handle
        int sndbuf = 32768;
        int rcvbuf = 32768;
 
-       memset(rth, 0, sizeof(rth));
+       memset(rth, 0, sizeof(*rth));
 
        rth->fd = socket(AF_NETLINK, SOCK_RAW, protocol);
        if (rth->fd < 0) {
diff -r 63594ce1708f -r 742dde457258 
tools/xenstat/libxenstat/src/xenstat_linux.c
--- a/tools/xenstat/libxenstat/src/xenstat_linux.c      Wed Feb 13 09:31:48 
2013 +0100
+++ b/tools/xenstat/libxenstat/src/xenstat_linux.c      Wed Feb 13 17:00:15 
2013 +0000
@@ -113,7 +113,7 @@ int parseNetDevLine(char *line, char *if
 
        /* Initialize all variables called has passed as non-NULL to zeros */
        if (iface != NULL)
-               memset(iface, 0, sizeof(iface));
+               memset(iface, 0, sizeof(*iface));
        if (rxBytes != NULL)
                *rxBytes = 0;
        if (rxPackets != NULL)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.