[powerdebug 02/14] save some bytes by allocating dynamically the string option
Daniel Lezcano
daniel.lezcano at free.fr
Tue Mar 22 11:40:05 UTC 2011
From: Daniel Lezcano <dlezcano at fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano at fr.ibm.com>
---
powerdebug.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/powerdebug.c b/powerdebug.c
index 4c2400b..3529459 100644
--- a/powerdebug.c
+++ b/powerdebug.c
@@ -85,7 +85,7 @@ struct powerdebug_options {
int sensors;
int clocks;
int ticktime;
- char clkarg[64];
+ char *clkarg;
};
int getoptions(int argc, char *argv[], struct powerdebug_options *options)
@@ -118,7 +118,11 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options)
break;
case 'p':
options->findparent = 1;
- strcpy(options->clkarg, optarg);
+ options->clkarg = strdup(optarg);
+ if (!options->clkarg) {
+ fprintf(stderr, "failed to allocate memory");
+ return -1;
+ }
break;
case 't':
options->ticktime = strtod(optarg, NULL);
--
1.7.1
More information about the linaro-dev
mailing list