From 633f4efee8aabdaa7e3827cfe1af15e4c7842bdc Mon Sep 17 00:00:00 2001 From: midipix Date: Thu, 9 Aug 2018 05:41:38 -0400 Subject: front-end utility: slbt_main(): remove the redundant argc parameter. --- include/slibtool/slibtool.h | 2 +- project/overrides.mk | 1 + src/driver/slbt_amain.c | 18 +++++++++++------- src/slibtool.c | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h index ac0f0ce..e06ef79 100644 --- a/include/slibtool/slibtool.h +++ b/include/slibtool/slibtool.h @@ -290,7 +290,7 @@ slbt_api int slbt_copy_file (const struct slbt_driver_ctx *, struct slbt_api int slbt_dump_machine (const char * compiler, char * machine, size_t bufsize); /* utility api */ -slbt_api int slbt_main (int, char **, char **, +slbt_api int slbt_main (char **, char **, const struct slbt_fd_ctx *); slbt_api int slbt_output_config (const struct slbt_driver_ctx *); diff --git a/project/overrides.mk b/project/overrides.mk index e69de29..4ac3b36 100644 --- a/project/overrides.mk +++ b/project/overrides.mk @@ -0,0 +1 @@ +src/$(PACKAGE).o: CFLAGS_CONFIG += -Wno-unused-parameter diff --git a/src/driver/slbt_amain.c b/src/driver/slbt_amain.c index a331b3b..e0d6bb9 100644 --- a/src/driver/slbt_amain.c +++ b/src/driver/slbt_amain.c @@ -83,10 +83,10 @@ static int slbt_exit(struct slbt_driver_ctx * dctx, int ret) return ret; } -int slbt_main(int argc, char ** argv, char ** envp, - const struct slbt_fd_ctx * fdctx) +int slbt_main(char ** argv, char ** envp, const struct slbt_fd_ctx * fdctx) { int ret; + const char * harg; int fdout; uint64_t flags; struct slbt_driver_ctx * dctx; @@ -97,11 +97,15 @@ int slbt_main(int argc, char ** argv, char ** envp, flags = SLBT_DRIVER_FLAGS; fdout = fdctx ? fdctx->fdout : STDOUT_FILENO; + /* harg */ + harg = (!argv || !argv[0] || !argv[1] || argv[2]) + ? 0 : argv[1]; + /* --version only? */ - if ((argc == 2) && (!strcmp(argv[1],"--version") - || !strcmp(argv[1],"--help-all") - || !strcmp(argv[1],"--help") - || !strcmp(argv[1],"-h"))) { + if (harg && (!strcmp(harg,"--version") + || !strcmp(harg,"--help-all") + || !strcmp(harg,"--help") + || !strcmp(harg,"-h"))) { sargv[0] = argv[0]; sargv[1] = argv[1]; sargv[2] = "--mode=compile"; @@ -153,7 +157,7 @@ int slbt_main(int argc, char ** argv, char ** envp, /* driver context */ if ((ret = slbt_get_driver_ctx(argv,envp,flags,fdctx,&dctx))) return (ret == SLBT_USAGE) - ? !--argc + ? !argv || !argv[0] || !argv[1] : SLBT_ERROR; if (dctx->cctx->drvflags & SLBT_DRIVER_VERSION) diff --git a/src/slibtool.c b/src/slibtool.c index a21c9f1..130474e 100644 --- a/src/slibtool.c +++ b/src/slibtool.c @@ -8,5 +8,5 @@ int main(int argc, char ** argv, char ** envp) { - return slbt_main(argc,argv,envp,0); + return slbt_main(argv,envp,0); } -- cgit v1.2.3