aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2020-12-30 00:16:27 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2020-12-30 00:16:27 +0100
commitb230ff9d8f1a393c13f338b030cace0899d5ec26 (patch)
treed3072de8cd68ba2527d179facd026213fd94cb60
parent04e0d8e579b289178b0303a92c705012237f4ca3 (diff)
downloadbusybox-b230ff9d8f1a393c13f338b030cace0899d5ec26.tar.gz
*: use fopen helpers where appropriate
function old new delta finalize 348 343 -5 parse_resolvconf 306 299 -7 list_i2c_busses_and_exit 495 483 -12 bootchartd_main 1091 1076 -15 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-39) Total: -39 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--init/bootchartd.c10
-rw-r--r--miscutils/i2c_tools.c6
-rw-r--r--networking/nslookup.c2
3 files changed, 9 insertions, 9 deletions
diff --git a/init/bootchartd.c b/init/bootchartd.c
index 750f67356..ae1ee9d9a 100644
--- a/init/bootchartd.c
+++ b/init/bootchartd.c
@@ -218,10 +218,10 @@ static char *make_tempdir(void)
static void do_logging(unsigned sample_period_us, int process_accounting)
{
- FILE *proc_stat = xfopen("proc_stat.log", "w");
- FILE *proc_diskstats = xfopen("proc_diskstats.log", "w");
- //FILE *proc_netdev = xfopen("proc_netdev.log", "w");
- FILE *proc_ps = xfopen("proc_ps.log", "w");
+ FILE *proc_stat = xfopen_for_write("proc_stat.log");
+ FILE *proc_diskstats = xfopen_for_write("proc_diskstats.log");
+ //FILE *proc_netdev = xfopen_for_write("proc_netdev.log");
+ FILE *proc_ps = xfopen_for_write("proc_ps.log");
int look_for_login_process = (getppid() == 1);
unsigned count = 60*1000*1000 / sample_period_us; /* ~1 minute */
@@ -268,7 +268,7 @@ static void finalize(char *tempdir, const char *prog, int process_accounting)
//local pacct=
//[ -e kernel_pacct ] && pacct=kernel_pacct
- FILE *header_fp = xfopen("header", "w");
+ FILE *header_fp = xfopen_for_write("header");
if (process_accounting)
acct(NULL);
diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c
index cda17ee00..48135921d 100644
--- a/miscutils/i2c_tools.c
+++ b/miscutils/i2c_tools.c
@@ -1149,12 +1149,12 @@ static void NORETURN list_i2c_busses_and_exit(void)
/* Simple version for ISA chips. */
snprintf(path, NAME_MAX, "%s/%s/name",
i2cdev_path, de->d_name);
- fp = fopen(path, "r");
+ fp = fopen_for_read(path);
if (fp == NULL) {
snprintf(path, NAME_MAX,
"%s/%s/device/name",
i2cdev_path, de->d_name);
- fp = fopen(path, "r");
+ fp = fopen_for_read(path);
}
/* Non-ISA chips require the hard-way. */
@@ -1175,7 +1175,7 @@ static void NORETURN list_i2c_busses_and_exit(void)
"%s/%s/device/%s/name",
i2cdev_path, de->d_name,
subde->d_name);
- fp = fopen(path, "r");
+ fp = fopen_for_read(path);
break;
}
}
diff --git a/networking/nslookup.c b/networking/nslookup.c
index dda22de0e..5aa2b35d2 100644
--- a/networking/nslookup.c
+++ b/networking/nslookup.c
@@ -697,7 +697,7 @@ static void parse_resolvconf(void)
{
FILE *resolv;
- resolv = fopen("/etc/resolv.conf", "r");
+ resolv = fopen_for_read("/etc/resolv.conf");
if (resolv) {
char line[512]; /* "search" is defined to be up to 256 chars */