9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Arne Meyer <meyer.arne83@netcologne.de>
To: "9front@9front.org" <9front@9front.org>
Subject: [9front] [patch] remove redundant memsets after emalloc9p in cifs
Date: Mon, 14 Nov 2022 20:23:50 +0100 (CET)	[thread overview]
Message-ID: <908205271.4681026.1668453830581@comcenter.netcologne.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 64 bytes --]

Found these while looking through /sys/src/cmd.

Greetings,
Arne

[-- Attachment #2: cifs.patch --]
[-- Type: application/octet-stream, Size: 2880 bytes --]

diff e5d29a2bd91951a24fccecd958416856cecef444 uncommitted
--- 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
@@ -333,7 +333,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;
@@ -360,7 +359,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++){

             reply	other threads:[~2022-11-14 19:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-14 19:23 Arne Meyer [this message]
2022-12-02 16:22 ` Arne Meyer
2022-12-16 18:28   ` Arne Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=908205271.4681026.1668453830581@comcenter.netcologne.de \
    --to=meyer.arne83@netcologne.de \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).