summaryrefslogtreecommitdiff
path: root/init/bootchartd.c
diff options
context:
space:
mode:
authorKeisuke Yasui2010-06-28 16:04:00 +0200
committerDenys Vlasenko2010-06-28 16:05:54 +0200
commitc03fb3cd7d6b41706a4ade372c5df9c6b951a51c (patch)
tree21124b2ec0addd7b64ea9319fd3bb6fca2fb787f /init/bootchartd.c
parentff37799dfe0e6e8fb9b971a2aeb4076d8a3784ec (diff)
downloadbusybox-c03fb3cd7d6b41706a4ade372c5df9c6b951a51c.zip
busybox-c03fb3cd7d6b41706a4ade372c5df9c6b951a51c.tar.gz
bootchartd: fix sample period calculations
Signed-off-by: Keisuke Yasui <keisuke.yasui@toshiba.co.jp> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'init/bootchartd.c')
-rw-r--r--init/bootchartd.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/init/bootchartd.c b/init/bootchartd.c
index 4e15da4..42b98c8 100644
--- a/init/bootchartd.c
+++ b/init/bootchartd.c
@@ -197,7 +197,7 @@ static char *make_tempdir(void)
return tempdir;
}
-static void do_logging(int sample_period_us)
+static void do_logging(unsigned sample_period_us)
{
//# Enable process accounting if configured
//if [ "$PROCESS_ACCOUNTING" = "yes" ]; then
@@ -210,7 +210,7 @@ static void do_logging(int sample_period_us)
//FILE *proc_netdev = xfopen("proc_netdev.log", "w");
FILE *proc_ps = xfopen("proc_ps.log", "w");
int look_for_login_process = (getppid() == 1);
- unsigned count = 60*1000*1000 / (200*1000); /* ~1 minute */
+ unsigned count = 60*1000*1000 / sample_period_us; /* ~1 minute */
while (--count && !bb_got_signal) {
char *p;
@@ -235,8 +235,8 @@ static void do_logging(int sample_period_us)
/* dump_procs saw a getty or {g,k,x}dm
* stop logging in 2 seconds:
*/
- if (count > 2*1000*1000 / (200*1000))
- count = 2*1000*1000 / (200*1000);
+ if (count > 2*1000*1000 / sample_period_us)
+ count = 2*1000*1000 / sample_period_us;
}
fflush_all();
wait_more:
@@ -325,7 +325,7 @@ static void finalize(char *tempdir, const char *prog)
int bootchartd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int bootchartd_main(int argc UNUSED_PARAM, char **argv)
{
- int sample_period_us;
+ unsigned sample_period_us;
pid_t parent_pid, logger_pid;
smallint cmd;
enum {
@@ -372,6 +372,8 @@ int bootchartd_main(int argc UNUSED_PARAM, char **argv)
}
config_close(parser);
}
+ if ((int)sample_period_us <= 0)
+ sample_period_us = 1; /* prevent division by 0 */
/* Create logger child: */
logger_pid = fork_or_rexec(argv);