diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-09-09 12:24:19 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-09-09 12:24:19 +0000 |
commit | 5dff2613d78e3a97fb2f0173b729e225278981ab (patch) | |
tree | 98f3e605a5b17bffc9e1f087907bf15049d6e717 | |
parent | 6d51db74a9a69bd95cd1130fa8149dda21fb7531 (diff) | |
download | busybox-w32-5dff2613d78e3a97fb2f0173b729e225278981ab.tar.gz busybox-w32-5dff2613d78e3a97fb2f0173b729e225278981ab.tar.bz2 busybox-w32-5dff2613d78e3a97fb2f0173b729e225278981ab.zip |
using [xa]sprintf for string concatenation is neat and saves
~100 bytes according to bloatcheck. Also this fixes bug in rpm
git-svn-id: svn://busybox.net/trunk/busybox@16081 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | archival/gzip.c | 4 | ||||
-rw-r--r-- | archival/rpm.c | 3 | ||||
-rw-r--r-- | coreutils/tr.c | 2 | ||||
-rw-r--r-- | e2fsprogs/ext2fs/mkjournal.c | 5 | ||||
-rw-r--r-- | procps/sysctl.c | 7 | ||||
-rw-r--r-- | sysklogd/logger.c | 2 |
6 files changed, 10 insertions, 13 deletions
diff --git a/archival/gzip.c b/archival/gzip.c index 37fefbf6a..ad2c24df1 100644 --- a/archival/gzip.c +++ b/archival/gzip.c | |||
@@ -1212,9 +1212,7 @@ int gzip_main(int argc, char **argv) | |||
1212 | time_stamp = statBuf.st_ctime; | 1212 | time_stamp = statBuf.st_ctime; |
1213 | 1213 | ||
1214 | if (!tostdout) { | 1214 | if (!tostdout) { |
1215 | path = xmalloc(strlen(argv[i]) + 4); | 1215 | path = xasprintf("%s.gz", argv[i]); |
1216 | strcpy(path, argv[i]); | ||
1217 | strcat(path, ".gz"); | ||
1218 | 1216 | ||
1219 | /* Open output file */ | 1217 | /* Open output file */ |
1220 | #if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1) && defined O_NOFOLLOW | 1218 | #if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1) && defined O_NOFOLLOW |
diff --git a/archival/rpm.c b/archival/rpm.c index d399e0ea2..a459839d9 100644 --- a/archival/rpm.c +++ b/archival/rpm.c | |||
@@ -290,8 +290,7 @@ static void fileaction_dobackup(char *filename, int fileref) | |||
290 | if (rpm_getint(RPMTAG_FILEFLAGS, fileref) & RPMFILE_CONFIG) { /* Only need to backup config files */ | 290 | if (rpm_getint(RPMTAG_FILEFLAGS, fileref) & RPMFILE_CONFIG) { /* Only need to backup config files */ |
291 | stat_res = lstat (filename, &oldfile); | 291 | stat_res = lstat (filename, &oldfile); |
292 | if (stat_res == 0 && S_ISREG(oldfile.st_mode)) { /* File already exists - really should check MD5's etc to see if different */ | 292 | if (stat_res == 0 && S_ISREG(oldfile.st_mode)) { /* File already exists - really should check MD5's etc to see if different */ |
293 | newname = xstrdup(filename); | 293 | newname = xasprintf("%s.rpmorig", filename); |
294 | newname = strcat(newname, ".rpmorig"); | ||
295 | copy_file(filename, newname, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS); | 294 | copy_file(filename, newname, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS); |
296 | remove_file(filename, FILEUTILS_RECUR | FILEUTILS_FORCE); | 295 | remove_file(filename, FILEUTILS_RECUR | FILEUTILS_FORCE); |
297 | free(newname); | 296 | free(newname); |
diff --git a/coreutils/tr.c b/coreutils/tr.c index 6eb86750d..f2c9065d1 100644 --- a/coreutils/tr.c +++ b/coreutils/tr.c | |||
@@ -128,7 +128,7 @@ static unsigned int expand(const char *arg, char *buffer) | |||
128 | for (i = 'A'; i <= 'Z'; i++) | 128 | for (i = 'A'; i <= 'Z'; i++) |
129 | *buffer++ = i; | 129 | *buffer++ = i; |
130 | else if (strncmp(arg, "space", 5) == 0) { | 130 | else if (strncmp(arg, "space", 5) == 0) { |
131 | const char s[] = "\t\n\v\f\r "; | 131 | const char s[] = "\t\n\v\f\r "; |
132 | strcat((char*)buffer, s); | 132 | strcat((char*)buffer, s); |
133 | buffer += sizeof(s) - 1; | 133 | buffer += sizeof(s) - 1; |
134 | } | 134 | } |
diff --git a/e2fsprogs/ext2fs/mkjournal.c b/e2fsprogs/ext2fs/mkjournal.c index c23ed9021..5bdd34682 100644 --- a/e2fsprogs/ext2fs/mkjournal.c +++ b/e2fsprogs/ext2fs/mkjournal.c | |||
@@ -322,8 +322,9 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size, int flags) | |||
322 | char jfile[1024]; | 322 | char jfile[1024]; |
323 | int fd, mount_flags, f; | 323 | int fd, mount_flags, f; |
324 | 324 | ||
325 | if ((retval = ext2fs_check_mount_point(fs->device_name, &mount_flags, | 325 | retval = ext2fs_check_mount_point(fs->device_name, &mount_flags, |
326 | jfile, sizeof(jfile)-10))) | 326 | jfile, sizeof(jfile)-10); |
327 | if (retval) | ||
327 | return retval; | 328 | return retval; |
328 | 329 | ||
329 | if (mount_flags & EXT2_MF_MOUNTED) { | 330 | if (mount_flags & EXT2_MF_MOUNTED) { |
diff --git a/procps/sysctl.c b/procps/sysctl.c index 03a03889e..297a12a85 100644 --- a/procps/sysctl.c +++ b/procps/sysctl.c | |||
@@ -129,7 +129,7 @@ int sysctl_preload_file(const char *filename, int output) | |||
129 | } | 129 | } |
130 | 130 | ||
131 | while (fgets(oneline, sizeof(oneline) - 1, fp)) { | 131 | while (fgets(oneline, sizeof(oneline) - 1, fp)) { |
132 | oneline[sizeof(oneline) - 1] = 0; | 132 | oneline[sizeof(oneline) - 1] = '\0'; |
133 | lineno++; | 133 | lineno++; |
134 | trim(oneline); | 134 | trim(oneline); |
135 | ptr = (char *) oneline; | 135 | ptr = (char *) oneline; |
@@ -156,9 +156,8 @@ int sysctl_preload_file(const char *filename, int output) | |||
156 | 156 | ||
157 | while ((*value == ' ' || *value == '\t') && *value != 0) | 157 | while ((*value == ' ' || *value == '\t') && *value != 0) |
158 | value++; | 158 | value++; |
159 | strcpy(buffer, name); | 159 | /* safe because sizeof(oneline) == sizeof(buffer) */ |
160 | strcat(buffer, "="); | 160 | sprintf(buffer, "%s=%s", name, value); |
161 | strcat(buffer, value); | ||
162 | sysctl_write_setting(buffer, output); | 161 | sysctl_write_setting(buffer, output); |
163 | } | 162 | } |
164 | fclose(fp); | 163 | fclose(fp); |
diff --git a/sysklogd/logger.c b/sysklogd/logger.c index ea093ed52..762e70ff7 100644 --- a/sysklogd/logger.c +++ b/sysklogd/logger.c | |||
@@ -138,7 +138,7 @@ int logger_main(int argc, char **argv) | |||
138 | len += strlen(*argv); | 138 | len += strlen(*argv); |
139 | message = xrealloc(message, len); | 139 | message = xrealloc(message, len); |
140 | if(!i) | 140 | if(!i) |
141 | message[0] = 0; | 141 | message[0] = '\0'; |
142 | else | 142 | else |
143 | strcat(message, " "); | 143 | strcat(message, " "); |
144 | strcat(message, *argv); | 144 | strcat(message, *argv); |