Skip to contentSkip to conversation

xfstests: memset proper length in resvtest.c

PATCH In review Eric Sandeen 3 participants 3 messages Mar 4, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfstests: memset proper length in resvtest.c

sizeof(pointer) is not very relevant; sizeof(*pointer) is a bit more so.

---

src/resvtest.c +1 -1
index 037d9ea..a07f503 100644
@@ -73,7 +73,7 @@ main(int argc, char **argv)
 		perror("open");
 		exit(1);
 	}
-	memset(writebuffer, 'A', sizeof(writebuffer));
+	memset(writebuffer, 'A', sizeof(*writebuffer));
 
 	unlink(filename);
 	writefd = open(filename, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#1 lore raw
Quoted 11 lines · Eric Sandeen

sizeof(pointer) is not very relevant; sizeof(*pointer) is a bit more so.

---

src/resvtest.c +0 -0
index 037d9ea..a07f503 100644

src/resvtest.c main(int argc, char **argv) · line 77

Quoted 6 lines
src/resvtest.c +1 -1
@@ -73,7 +73,7 @@ main(int argc, char **argv)
 		perror("open");
 		exit(1);
 	}
-	memset(writebuffer, 'A', sizeof(writebuffer));
+	memset(writebuffer, 'A', sizeof(*writebuffer));
 

It's not clear to me how much this is intending to write/read. If the entire buffer, we should probably use the buffer size. sizeof(*writebuffer) is a single byte, no?

Also, there are other instances of the same thing throughout this file. I think they need to be consistent, in any event, for the test to work.

Brian

Quoted 7 lines
src/resvtest.c +0 -0
 	unlink(filename);
 	writefd = open(filename, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#2 lore raw
Quoted 23 lines · Brian Foster
Quoted 11 lines · Eric Sandeen

sizeof(pointer) is not very relevant; sizeof(*pointer) is a bit more so.

---

src/resvtest.c +0 -0
index 037d9ea..a07f503 100644

src/resvtest.c main(int argc, char **argv) · line 77

Quoted 6 lines
src/resvtest.c +1 -1
@@ -73,7 +73,7 @@ main(int argc, char **argv)
 		perror("open");
 		exit(1);
 	}
-	memset(writebuffer, 'A', sizeof(writebuffer));
+	memset(writebuffer, 'A', sizeof(*writebuffer));
 

It's not clear to me how much this is intending to write/read. If the entire buffer, we should probably use the buffer size. sizeof(*writebuffer) is a single byte, no?

Quoted 2 lines

Also, there are other instances of the same thing throughout this file. I think they need to be consistent, in any event, for the test to work.

yeah, sorry, I was in a bit too much of a rush; just disregard this for now I guess. too-quick reaction to a gcc compile warning.

-Eric

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs