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@durham.ac.uk>
Committed-by: Keir Fraser <keir@xen.org>
This commit is contained in:
Michael Young committed 2013-02-13 17:00:15 +00:00
1 parent b61ed421d2
commit d119301b58
6 files changed
+6 -6

No files matched your search

+1 -1
View File
@@ -174,7 +174,7 @@ void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
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 */
+1 -1
View File
@@ -333,7 +333,7 @@ int kdd_get_regs(kdd_guest *g, int cpuid, kdd_regs *r, int w64)
if (!cpu)
return -1;
memset(r, 0, sizeof(r));
memset(r, 0, sizeof(*r));
if (w64)
kdd_get_regs_x86_64(cpu, &r->r64);
+1 -1
View File
@@ -266,7 +266,7 @@ int xc_dom_boot_image(struct xc_dom_image *dom)
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);
+1 -1
View File
@@ -378,7 +378,7 @@ static int qmp_open(libxl__qmp_handler *qmp, const char *qmp_socket_path,
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));
@@ -37,7 +37,7 @@ int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions,
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) {
+1 -1
View File
@@ -113,7 +113,7 @@ int parseNetDevLine(char *line, char *iface, unsigned long long *rxBytes, unsign
/* 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)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.