[Toybox] [PATCH] bzero -> memset - a sufficiently useful compiler will optimize away differences
Nathan McSween
nwmcsween at gmail.com
Fri Feb 17 00:43:49 PST 2012
# HG changeset patch
# User Nathan McSween <nwmcsween at gmail.com>
# Date 1329461552 0
# Node ID bde1bb9b95cd681859672f1e35f0ac32bdb68478
# Parent 64fdb6cd587c3041b94ee98e2a0f5668cae2f5a0
bzero -> memset - a sufficiently useful compiler will optimize away differences
diff -r 64fdb6cd587c -r bde1bb9b95cd lib/args.c
--- a/lib/args.c Fri Feb 17 06:44:44 2012 +0000
+++ b/lib/args.c Fri Feb 17 06:52:32 2012 +0000
@@ -181,7 +181,7 @@
int i;
// Parse option format string
- bzero(gof, sizeof(struct getoptflagstate));
+ memset(gof, '\0', sizeof(struct getoptflagstate));
gof->maxargs = INT_MAX;
if (!options) return;
diff -r 64fdb6cd587c -r bde1bb9b95cd lib/lib.c
--- a/lib/lib.c Fri Feb 17 06:44:44 2012 +0000
+++ b/lib/lib.c Fri Feb 17 06:52:32 2012 +0000
@@ -91,7 +91,7 @@
void *xzalloc(size_t size)
{
void *ret = xmalloc(size);
- bzero(ret, size);
+ memset(ret, '\0', size);
return ret;
}
diff -r 64fdb6cd587c -r bde1bb9b95cd main.c
--- a/main.c Fri Feb 17 06:44:44 2012 +0000
+++ b/main.c Fri Feb 17 06:52:32 2012 +0000
@@ -84,7 +84,7 @@
// Free old toys contents (to be reentrant)
if (toys.optargs != toys.argv+1) free(toys.optargs);
- bzero(&toys, sizeof(struct toy_context));
+ memset(&toys, '\0', sizeof(struct toy_context));
toys.which = which;
toys.argv = argv;
diff -r 64fdb6cd587c -r bde1bb9b95cd toys/toysh.c
--- a/toys/toysh.c Fri Feb 17 06:44:44 2012 +0000
+++ b/toys/toysh.c Fri Feb 17 06:52:32 2012 +0000
@@ -291,7 +291,7 @@
// This fakes lots of what toybox_main() does.
memcpy(&temp, &toys, sizeof(struct toy_context));
- bzero(&toys, sizeof(struct toy_context));
+ memset(&toys, '\0', sizeof(struct toy_context));
toy_init(tl, cmd->argv);
tl->toy_main();
cmd->pid = toys.exitval;
More information about the Toybox
mailing list