Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Arm Trusted Firmware
Commits
8874924e
Commit
8874924e
authored
Sep 19, 2016
by
danh-arm
Committed by
GitHub
Sep 19, 2016
Browse files
Merge pull request #710 from dp-arm/dp/fiptool-usage
fiptool: Invoke command specific usage function
parents
92455d89
85ee2778
Changes
1
Show whitespace changes
Inline
Side-by-side
tools/fiptool/fiptool.c
View file @
8874924e
...
@@ -373,7 +373,7 @@ static int info_cmd(int argc, char *argv[])
...
@@ -373,7 +373,7 @@ static int info_cmd(int argc, char *argv[])
int
i
;
int
i
;
if
(
argc
!=
2
)
if
(
argc
!=
2
)
usage
();
info_
usage
();
argc
--
,
argv
++
;
argc
--
,
argv
++
;
parse_fip
(
argv
[
0
],
&
toc_header
);
parse_fip
(
argv
[
0
],
&
toc_header
);
...
@@ -421,6 +421,7 @@ static int info_cmd(int argc, char *argv[])
...
@@ -421,6 +421,7 @@ static int info_cmd(int argc, char *argv[])
static
void
info_usage
(
void
)
static
void
info_usage
(
void
)
{
{
printf
(
"fiptool info FIP_FILENAME
\n
"
);
printf
(
"fiptool info FIP_FILENAME
\n
"
);
exit
(
1
);
}
}
static
int
pack_images
(
char
*
filename
,
uint64_t
toc_flags
)
static
int
pack_images
(
char
*
filename
,
uint64_t
toc_flags
)
...
@@ -554,7 +555,7 @@ static int create_cmd(int argc, char *argv[])
...
@@ -554,7 +555,7 @@ static int create_cmd(int argc, char *argv[])
int
i
;
int
i
;
if
(
argc
<
2
)
if
(
argc
<
2
)
usage
();
create_
usage
();
i
=
fill_common_opts
(
opts
,
required_argument
);
i
=
fill_common_opts
(
opts
,
required_argument
);
add_opt
(
opts
,
i
,
"plat-toc-flags"
,
required_argument
,
add_opt
(
opts
,
i
,
"plat-toc-flags"
,
required_argument
,
...
@@ -583,14 +584,14 @@ static int create_cmd(int argc, char *argv[])
...
@@ -583,14 +584,14 @@ static int create_cmd(int argc, char *argv[])
parse_plat_toc_flags
(
optarg
,
&
toc_flags
);
parse_plat_toc_flags
(
optarg
,
&
toc_flags
);
break
;
break
;
default:
default:
usage
();
create_
usage
();
}
}
}
}
argc
-=
optind
;
argc
-=
optind
;
argv
+=
optind
;
argv
+=
optind
;
if
(
argc
==
0
)
if
(
argc
==
0
)
usage
();
create_
usage
();
update_fip
();
update_fip
();
...
@@ -611,6 +612,7 @@ static void create_usage(void)
...
@@ -611,6 +612,7 @@ static void create_usage(void)
for
(;
toc_entry
->
cmdline_name
!=
NULL
;
toc_entry
++
)
for
(;
toc_entry
->
cmdline_name
!=
NULL
;
toc_entry
++
)
printf
(
" --%-16s FILENAME
\t
%s
\n
"
,
toc_entry
->
cmdline_name
,
printf
(
" --%-16s FILENAME
\t
%s
\n
"
,
toc_entry
->
cmdline_name
,
toc_entry
->
name
);
toc_entry
->
name
);
exit
(
1
);
}
}
static
int
update_cmd
(
int
argc
,
char
*
argv
[])
static
int
update_cmd
(
int
argc
,
char
*
argv
[])
...
@@ -623,7 +625,7 @@ static int update_cmd(int argc, char *argv[])
...
@@ -623,7 +625,7 @@ static int update_cmd(int argc, char *argv[])
int
i
;
int
i
;
if
(
argc
<
2
)
if
(
argc
<
2
)
usage
();
update_
usage
();
i
=
fill_common_opts
(
opts
,
required_argument
);
i
=
fill_common_opts
(
opts
,
required_argument
);
add_opt
(
opts
,
i
,
"out"
,
required_argument
,
'o'
);
add_opt
(
opts
,
i
,
"out"
,
required_argument
,
'o'
);
...
@@ -658,14 +660,14 @@ static int update_cmd(int argc, char *argv[])
...
@@ -658,14 +660,14 @@ static int update_cmd(int argc, char *argv[])
snprintf
(
outfile
,
sizeof
(
outfile
),
"%s"
,
optarg
);
snprintf
(
outfile
,
sizeof
(
outfile
),
"%s"
,
optarg
);
break
;
break
;
default:
default:
usage
();
update_
usage
();
}
}
}
}
argc
-=
optind
;
argc
-=
optind
;
argv
+=
optind
;
argv
+=
optind
;
if
(
argc
==
0
)
if
(
argc
==
0
)
usage
();
update_
usage
();
if
(
outfile
[
0
]
==
'\0'
)
if
(
outfile
[
0
]
==
'\0'
)
snprintf
(
outfile
,
sizeof
(
outfile
),
"%s"
,
argv
[
0
]);
snprintf
(
outfile
,
sizeof
(
outfile
),
"%s"
,
argv
[
0
]);
...
@@ -698,6 +700,7 @@ static void update_usage(void)
...
@@ -698,6 +700,7 @@ static void update_usage(void)
for
(;
toc_entry
->
cmdline_name
!=
NULL
;
toc_entry
++
)
for
(;
toc_entry
->
cmdline_name
!=
NULL
;
toc_entry
++
)
printf
(
" --%-16s FILENAME
\t
%s
\n
"
,
toc_entry
->
cmdline_name
,
printf
(
" --%-16s FILENAME
\t
%s
\n
"
,
toc_entry
->
cmdline_name
,
toc_entry
->
name
);
toc_entry
->
name
);
exit
(
1
);
}
}
static
int
unpack_cmd
(
int
argc
,
char
*
argv
[])
static
int
unpack_cmd
(
int
argc
,
char
*
argv
[])
...
@@ -710,7 +713,7 @@ static int unpack_cmd(int argc, char *argv[])
...
@@ -710,7 +713,7 @@ static int unpack_cmd(int argc, char *argv[])
int
i
;
int
i
;
if
(
argc
<
2
)
if
(
argc
<
2
)
usage
();
unpack_
usage
();
i
=
fill_common_opts
(
opts
,
required_argument
);
i
=
fill_common_opts
(
opts
,
required_argument
);
add_opt
(
opts
,
i
,
"force"
,
no_argument
,
'f'
);
add_opt
(
opts
,
i
,
"force"
,
no_argument
,
'f'
);
...
@@ -740,14 +743,14 @@ static int unpack_cmd(int argc, char *argv[])
...
@@ -740,14 +743,14 @@ static int unpack_cmd(int argc, char *argv[])
snprintf
(
outdir
,
sizeof
(
outdir
),
"%s"
,
optarg
);
snprintf
(
outdir
,
sizeof
(
outdir
),
"%s"
,
optarg
);
break
;
break
;
default:
default:
usage
();
unpack_
usage
();
}
}
}
}
argc
-=
optind
;
argc
-=
optind
;
argv
+=
optind
;
argv
+=
optind
;
if
(
argc
==
0
)
if
(
argc
==
0
)
usage
();
unpack_
usage
();
parse_fip
(
argv
[
0
],
NULL
);
parse_fip
(
argv
[
0
],
NULL
);
...
@@ -822,6 +825,7 @@ static void unpack_usage(void)
...
@@ -822,6 +825,7 @@ static void unpack_usage(void)
toc_entry
->
name
);
toc_entry
->
name
);
fputc
(
'\n'
,
stderr
);
fputc
(
'\n'
,
stderr
);
printf
(
"If no options are provided, all images will be unpacked.
\n
"
);
printf
(
"If no options are provided, all images will be unpacked.
\n
"
);
exit
(
1
);
}
}
static
int
remove_cmd
(
int
argc
,
char
*
argv
[])
static
int
remove_cmd
(
int
argc
,
char
*
argv
[])
...
@@ -834,7 +838,7 @@ static int remove_cmd(int argc, char *argv[])
...
@@ -834,7 +838,7 @@ static int remove_cmd(int argc, char *argv[])
int
i
;
int
i
;
if
(
argc
<
2
)
if
(
argc
<
2
)
usage
();
remove_
usage
();
i
=
fill_common_opts
(
opts
,
no_argument
);
i
=
fill_common_opts
(
opts
,
no_argument
);
add_opt
(
opts
,
i
,
"force"
,
no_argument
,
'f'
);
add_opt
(
opts
,
i
,
"force"
,
no_argument
,
'f'
);
...
@@ -860,14 +864,14 @@ static int remove_cmd(int argc, char *argv[])
...
@@ -860,14 +864,14 @@ static int remove_cmd(int argc, char *argv[])
snprintf
(
outfile
,
sizeof
(
outfile
),
"%s"
,
optarg
);
snprintf
(
outfile
,
sizeof
(
outfile
),
"%s"
,
optarg
);
break
;
break
;
default:
default:
usage
();
remove_
usage
();
}
}
}
}
argc
-=
optind
;
argc
-=
optind
;
argv
+=
optind
;
argv
+=
optind
;
if
(
argc
==
0
)
if
(
argc
==
0
)
usage
();
remove_
usage
();
if
(
outfile
[
0
]
!=
'\0'
&&
access
(
outfile
,
F_OK
)
==
0
&&
!
fflag
)
if
(
outfile
[
0
]
!=
'\0'
&&
access
(
outfile
,
F_OK
)
==
0
&&
!
fflag
)
log_errx
(
"File %s already exists, use --force to overwrite it"
,
log_errx
(
"File %s already exists, use --force to overwrite it"
,
...
@@ -912,6 +916,7 @@ static void remove_usage(void)
...
@@ -912,6 +916,7 @@ static void remove_usage(void)
for
(;
toc_entry
->
cmdline_name
!=
NULL
;
toc_entry
++
)
for
(;
toc_entry
->
cmdline_name
!=
NULL
;
toc_entry
++
)
printf
(
" --%-16s
\t
%s
\n
"
,
toc_entry
->
cmdline_name
,
printf
(
" --%-16s
\t
%s
\n
"
,
toc_entry
->
cmdline_name
,
toc_entry
->
name
);
toc_entry
->
name
);
exit
(
1
);
}
}
static
int
version_cmd
(
int
argc
,
char
*
argv
[])
static
int
version_cmd
(
int
argc
,
char
*
argv
[])
...
@@ -928,6 +933,7 @@ static int version_cmd(int argc, char *argv[])
...
@@ -928,6 +933,7 @@ static int version_cmd(int argc, char *argv[])
static
void
version_usage
(
void
)
static
void
version_usage
(
void
)
{
{
printf
(
"fiptool version
\n
"
);
printf
(
"fiptool version
\n
"
);
exit
(
1
);
}
}
static
int
help_cmd
(
int
argc
,
char
*
argv
[])
static
int
help_cmd
(
int
argc
,
char
*
argv
[])
...
@@ -940,10 +946,8 @@ static int help_cmd(int argc, char *argv[])
...
@@ -940,10 +946,8 @@ static int help_cmd(int argc, char *argv[])
for
(
i
=
0
;
i
<
NELEM
(
cmds
);
i
++
)
{
for
(
i
=
0
;
i
<
NELEM
(
cmds
);
i
++
)
{
if
(
strcmp
(
cmds
[
i
].
name
,
argv
[
0
])
==
0
&&
if
(
strcmp
(
cmds
[
i
].
name
,
argv
[
0
])
==
0
&&
cmds
[
i
].
usage
!=
NULL
)
{
cmds
[
i
].
usage
!=
NULL
)
cmds
[
i
].
usage
();
cmds
[
i
].
usage
();
break
;
}
}
}
if
(
i
==
NELEM
(
cmds
))
if
(
i
==
NELEM
(
cmds
))
printf
(
"No help for subcommand '%s'
\n
"
,
argv
[
0
]);
printf
(
"No help for subcommand '%s'
\n
"
,
argv
[
0
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment