summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2017-11-30 17:22:42 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-11-30 17:22:42 +1100
commit1ccd69266b2b71113d17de0d799e0de64aac2fb5 (patch)
tree8782eb3abb8d76deb692c55a3161c3d99e2929b0
parent0d97f635950d6746038ab8c14429be40501369a0 (diff)
downloadffs-1ccd69266b2b71113d17de0d799e0de64aac2fb5.zip
ffs-1ccd69266b2b71113d17de0d799e0de64aac2fb5.tar.gz
fpart: make test run valgrind clean
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r--fpart/src/main.c27
-rw-r--r--fpart/src/main.h12
2 files changed, 29 insertions, 10 deletions
diff --git a/fpart/src/main.c b/fpart/src/main.c
index 044ea93..679cdcb 100644
--- a/fpart/src/main.c
+++ b/fpart/src/main.c
@@ -236,12 +236,15 @@ static int process_argument(args_t * args, int opt, const char *optarg)
args->user = strdup(optarg);
break;
case o_POFFSET: /* partition-offset */
+ free(args->poffset);
args->poffset = strdup(optarg);
break;
case o_TARGET: /* target */
+ free(args->target);
args->target = strdup(optarg);
break;
case o_NAME: /* name */
+ free(args->name);
args->name = strdup(optarg);
break;
case o_OFFSET: /* offset */
@@ -460,6 +463,21 @@ static int process_args(args_t * args)
return rc;
}
+static void free_args(args_t * args)
+{
+ free(args->short_name);
+ free(args->name);
+ free(args->target);
+ free(args->offset);
+ free(args->poffset);
+ free(args->size);
+ free(args->block);
+ free(args->user);
+ free(args->value);
+ free(args->flags);
+ free(args->pad);
+}
+
static void args_dump(args_t * args)
{
assert(args != NULL);
@@ -579,6 +597,7 @@ error:
err_code(err), err_size(err), (char *)err_data(err));
}
+ free_args(&args);
return rc;
}
@@ -587,8 +606,8 @@ static void __ctor__(void)
{
page_size = sysconf(_SC_PAGESIZE);
- args.short_name = program_invocation_short_name;
- args.poffset = "0x3F0000,0x7F0000";
- args.target = "/dev/mtdblock/sfc.of";
- args.name = ".*";
+ args.short_name = strdup(program_invocation_short_name);
+ args.poffset = strdup("0x3F0000,0x7F0000");
+ args.target = strdup("/dev/mtdblock/sfc.of");
+ args.name = strdup(".*");
}
diff --git a/fpart/src/main.h b/fpart/src/main.h
index 35160c6..1662fa0 100644
--- a/fpart/src/main.h
+++ b/fpart/src/main.h
@@ -76,7 +76,7 @@ typedef enum {
} flag_t;
typedef struct {
- const char *short_name;
+ char *short_name;
/* target */
const char *path;
@@ -85,11 +85,11 @@ typedef struct {
cmd_t cmd;
/* options */
- const char *name, *target;
- const char *offset, *poffset;
- const char *size, *block;
- const char *user, *value;
- const char *flags, *pad;
+ char *name, *target;
+ char *offset, *poffset;
+ char *size, *block;
+ char *user, *value;
+ char *flags, *pad;
/* flags */
flag_t force, logical;
OpenPOWER on IntegriCloud