shithub: riscv

Download patch

ref: 812e7515d6f9d102ebaeb89331ccb2a3b45d8c57
parent: dab1b23cf5049a8f51a7135a7b0ee3882155dc42
author: Ori Bernstein <[email protected]>
date: Sun Dec 18 20:42:31 EST 2022

cifs: remove redundant memsets after emalloc9p (thanks Arne Meyer)

--- a/sys/src/cmd/cifs/auth.c
+++ b/sys/src/cmd/cifs/auth.c
@@ -55,7 +55,6 @@
 		sysfatal("cannot get key - %r");
 
 	ap = emalloc9p(sizeof(Auth));
-	memset(ap, 0, sizeof(ap));
 	ap->user = estrdup9p(up->user);
 	ap->windom = estrdup9p(windom);
 
@@ -87,7 +86,6 @@
 		sysfatal("bad response size");
 
 	ap = emalloc9p(sizeof(Auth));
-	memset(ap, 0, sizeof(ap));
 	ap->user = estrdup9p(user);
 	ap->windom = estrdup9p(windom);
 
--- a/sys/src/cmd/cifs/cifs.c
+++ b/sys/src/cmd/cifs/cifs.c
@@ -28,7 +28,6 @@
 	}
 
 	s = emalloc9p(sizeof(Session));
-	memset(s, 0, sizeof(Session));
 
 	s->fd = fd;
 	s->nbt = nbt;
@@ -76,7 +75,6 @@
 	}
 
 	p = emalloc9p(sizeof(Pkt) + MTU);
-	memset(p, 0, sizeof(Pkt) +MTU);
 
 	p->buf = (uchar *)p + sizeof(Pkt);
 	p->s = s;
--- a/sys/src/cmd/cifs/dfs.c
+++ b/sys/src/cmd/cifs/dfs.c
@@ -379,7 +379,6 @@
 		sysfatal("no memory: %r");
 
 	cp = emalloc9p(sizeof(Dfscache));
-	memset(cp, 0, sizeof(Dfscache));
 	cp->rtt = SINT_MAX;
 
 	if(redir1(s, unc, cp, 1) == -1){
--- a/sys/src/cmd/cifs/main.c
+++ b/sys/src/cmd/cifs/main.c
@@ -326,7 +326,6 @@
 	r->fid->qid = r->ofcall.qid;
 
 	a = r->fid->aux = emalloc9p(sizeof(Aux));
-	memset(a, 0, sizeof(Aux));
 	a->path = estrdup9p("/");
 	a->sp = nil;
 	a->fh = -1;
@@ -353,7 +352,6 @@
 
 	fid->aux = a;
 
-	memset(a, 0, sizeof(Aux));
 	a->sh = -1;
 	a->fh = -1;
 	a->sp = oa->sp;
--- a/sys/src/cmd/cifs/trans.c
+++ b/sys/src/cmd/cifs/trans.c
@@ -148,7 +148,6 @@
 
 	if(ngot == 0){
 		*ent = emalloc9p(sizeof(Share) * navail);
-		memset(*ent, 0, sizeof(Share) * navail);
 	}
 
 	q = *ent + ngot;
@@ -274,7 +273,6 @@
 
 	if(ngot == 0){
 		*sip = emalloc9p(sizeof(Sessinfo) * navail);
-		memset(*sip, 0, sizeof(Sessinfo) * navail);
 	}
 
 	q = *sip + ngot;
@@ -333,7 +331,6 @@
 	}
 
 	*nlp = emalloc9p(sizeof(Namelist) * navail);
-	memset(*nlp, 0, sizeof(Namelist) * navail);
 
 	q = *nlp + ngot;
 	while(ngot < navail && nret--){
@@ -389,7 +386,6 @@
 	}
 
 	*nlp = emalloc9p(sizeof(Namelist) * navail);
-	memset(*nlp, 0, sizeof(Namelist) * navail);
 
 	q = *nlp + ngot;
 	while(ngot < navail && nret--){
@@ -443,7 +439,6 @@
 	}
 
 	*nlp = emalloc9p(sizeof(Namelist) * navail);
-	memset(*nlp, 0, sizeof(Namelist) * navail);
 
 	q = *nlp + ngot;
 	while(ngot < navail && nret--){
@@ -502,7 +497,6 @@
 
 	if(ngot == 0){
 		*nlp = emalloc9p(sizeof(Namelist) * navail);
-		memset(*nlp, 0, sizeof(Namelist) * navail);
 	}
 	q = *nlp + ngot;
 	while(ngot < navail && nret--){
@@ -616,7 +610,6 @@
 	}
 
 	*si = emalloc9p(sizeof(Serverinfo) * navail);
-	memset(*si, 0, sizeof(Serverinfo) * navail);
 
 	q = *si;
 	for (; nret-- != 0 && ngot < navail; ngot++){
@@ -763,7 +756,6 @@
 
 	if(ngot == 0){
 		*fip = emalloc9p(sizeof(Fileinfo) * navail);
-		memset(*fip, 0, sizeof(Fileinfo) * navail);
 	}
 	q = *fip + ngot;
 	for(; nret-- && ngot < navail; ngot++){