From 9cac521f07550764e94c469d70b22ad5c194855a Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Sat, 9 Sep 2006 12:24:19 +0000 Subject: using [xa]sprintf for string concatenation is neat and saves ~100 bytes according to bloatcheck. Also this fixes bug in rpm --- procps/sysctl.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'procps') 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) } while (fgets(oneline, sizeof(oneline) - 1, fp)) { - oneline[sizeof(oneline) - 1] = 0; + oneline[sizeof(oneline) - 1] = '\0'; lineno++; trim(oneline); ptr = (char *) oneline; @@ -156,9 +156,8 @@ int sysctl_preload_file(const char *filename, int output) while ((*value == ' ' || *value == '\t') && *value != 0) value++; - strcpy(buffer, name); - strcat(buffer, "="); - strcat(buffer, value); + /* safe because sizeof(oneline) == sizeof(buffer) */ + sprintf(buffer, "%s=%s", name, value); sysctl_write_setting(buffer, output); } fclose(fp); -- cgit v1.2.3