about summary refs log tree commit diff stats
path: root/numericx.c
diff options
context:
space:
mode:
authorDaniel Santos <dacs.git@brilhante.top>2022-03-17 14:24:13 +0000
committerDaniel Santos <dacs.git@brilhante.top>2022-03-17 14:24:13 +0000
commitfd66c372859c42f2dee036df8e5b83bd56934427 (patch)
treecd4043681379d3a63112d3f4f2f6ffce358ef84c /numericx.c
parent3d304af497c697fcb7e54fb009839dd08e136970 (diff)
downloadnumericx-c-fd66c372859c42f2dee036df8e5b83bd56934427.tar.gz
invalid argument list of main() return E2BIG
 * If invalid number of arguments supplied to main(), return errno E2BIG
 * add Makefile rule to test memory leak of wrong number of arguments to
   main()

Signed-off-by: Daniel Santos <dacs.git@brilhante.top>
Diffstat (limited to 'numericx.c')
-rw-r--r--numericx.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/numericx.c b/numericx.c
index 9b3b8c3..d14fb4c 100644
--- a/numericx.c
+++ b/numericx.c
@@ -545,8 +545,9 @@ numericx_translate(char* from, bool from_units_on_the_end, bool from_first_numbe
  *
  * @param argv[] - one number as a string
  *
- * @return EXIT_SUCCESS in case of a successful number translation
+ * @return E2BIG in case of wrong number of arguments
  * @return EXIT_FAILURE in case of unsuccessful number translation
+ * @return EXIT_SUCCESS in case of a successful number translation
  */
 int
 main(int argc, char* argv[])
@@ -555,7 +556,7 @@ main(int argc, char* argv[])
 	if( !(argc == 2) )
 	{
 		fprintf(stderr, "usage: %s <number>\n", PROG_NAME);
-		exit(EXIT_FAILURE);
+		return E2BIG;
 	}
 
 	/* Number variables to be converted */