using [xa]sprintf for string concatenation is neat and saves
~100 bytes according to bloatcheck. Also this fixes bug in rpm
This commit is contained in:
parent
3526a1320a
commit
9cac521f07
@ -1212,9 +1212,7 @@ int gzip_main(int argc, char **argv)
|
|||||||
time_stamp = statBuf.st_ctime;
|
time_stamp = statBuf.st_ctime;
|
||||||
|
|
||||||
if (!tostdout) {
|
if (!tostdout) {
|
||||||
path = xmalloc(strlen(argv[i]) + 4);
|
path = xasprintf("%s.gz", argv[i]);
|
||||||
strcpy(path, argv[i]);
|
|
||||||
strcat(path, ".gz");
|
|
||||||
|
|
||||||
/* Open output file */
|
/* Open output file */
|
||||||
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1) && defined O_NOFOLLOW
|
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1) && defined O_NOFOLLOW
|
||||||
|
@ -290,8 +290,7 @@ static void fileaction_dobackup(char *filename, int fileref)
|
|||||||
if (rpm_getint(RPMTAG_FILEFLAGS, fileref) & RPMFILE_CONFIG) { /* Only need to backup config files */
|
if (rpm_getint(RPMTAG_FILEFLAGS, fileref) & RPMFILE_CONFIG) { /* Only need to backup config files */
|
||||||
stat_res = lstat (filename, &oldfile);
|
stat_res = lstat (filename, &oldfile);
|
||||||
if (stat_res == 0 && S_ISREG(oldfile.st_mode)) { /* File already exists - really should check MD5's etc to see if different */
|
if (stat_res == 0 && S_ISREG(oldfile.st_mode)) { /* File already exists - really should check MD5's etc to see if different */
|
||||||
newname = xstrdup(filename);
|
newname = xasprintf("%s.rpmorig", filename);
|
||||||
newname = strcat(newname, ".rpmorig");
|
|
||||||
copy_file(filename, newname, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS);
|
copy_file(filename, newname, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS);
|
||||||
remove_file(filename, FILEUTILS_RECUR | FILEUTILS_FORCE);
|
remove_file(filename, FILEUTILS_RECUR | FILEUTILS_FORCE);
|
||||||
free(newname);
|
free(newname);
|
||||||
|
@ -128,7 +128,7 @@ static unsigned int expand(const char *arg, char *buffer)
|
|||||||
for (i = 'A'; i <= 'Z'; i++)
|
for (i = 'A'; i <= 'Z'; i++)
|
||||||
*buffer++ = i;
|
*buffer++ = i;
|
||||||
else if (strncmp(arg, "space", 5) == 0) {
|
else if (strncmp(arg, "space", 5) == 0) {
|
||||||
const char s[] = "\t\n\v\f\r ";
|
const char s[] = "\t\n\v\f\r ";
|
||||||
strcat((char*)buffer, s);
|
strcat((char*)buffer, s);
|
||||||
buffer += sizeof(s) - 1;
|
buffer += sizeof(s) - 1;
|
||||||
}
|
}
|
||||||
|
@ -322,8 +322,9 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size, int flags)
|
|||||||
char jfile[1024];
|
char jfile[1024];
|
||||||
int fd, mount_flags, f;
|
int fd, mount_flags, f;
|
||||||
|
|
||||||
if ((retval = ext2fs_check_mount_point(fs->device_name, &mount_flags,
|
retval = ext2fs_check_mount_point(fs->device_name, &mount_flags,
|
||||||
jfile, sizeof(jfile)-10)))
|
jfile, sizeof(jfile)-10);
|
||||||
|
if (retval)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
if (mount_flags & EXT2_MF_MOUNTED) {
|
if (mount_flags & EXT2_MF_MOUNTED) {
|
||||||
|
@ -129,7 +129,7 @@ int sysctl_preload_file(const char *filename, int output)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (fgets(oneline, sizeof(oneline) - 1, fp)) {
|
while (fgets(oneline, sizeof(oneline) - 1, fp)) {
|
||||||
oneline[sizeof(oneline) - 1] = 0;
|
oneline[sizeof(oneline) - 1] = '\0';
|
||||||
lineno++;
|
lineno++;
|
||||||
trim(oneline);
|
trim(oneline);
|
||||||
ptr = (char *) oneline;
|
ptr = (char *) oneline;
|
||||||
@ -156,9 +156,8 @@ int sysctl_preload_file(const char *filename, int output)
|
|||||||
|
|
||||||
while ((*value == ' ' || *value == '\t') && *value != 0)
|
while ((*value == ' ' || *value == '\t') && *value != 0)
|
||||||
value++;
|
value++;
|
||||||
strcpy(buffer, name);
|
/* safe because sizeof(oneline) == sizeof(buffer) */
|
||||||
strcat(buffer, "=");
|
sprintf(buffer, "%s=%s", name, value);
|
||||||
strcat(buffer, value);
|
|
||||||
sysctl_write_setting(buffer, output);
|
sysctl_write_setting(buffer, output);
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -138,7 +138,7 @@ int logger_main(int argc, char **argv)
|
|||||||
len += strlen(*argv);
|
len += strlen(*argv);
|
||||||
message = xrealloc(message, len);
|
message = xrealloc(message, len);
|
||||||
if(!i)
|
if(!i)
|
||||||
message[0] = 0;
|
message[0] = '\0';
|
||||||
else
|
else
|
||||||
strcat(message, " ");
|
strcat(message, " ");
|
||||||
strcat(message, *argv);
|
strcat(message, *argv);
|
||||||
|
Loading…
Reference in New Issue
Block a user