You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ag...@apache.org on 2022/01/01 13:54:20 UTC
[incubator-nuttx-apps] branch master updated: Check for too many arguments to hostname
This is an automated email from the ASF dual-hosted git repository.
aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 6993c66 Check for too many arguments to hostname
6993c66 is described below
commit 6993c66389f4d537e3bc90f32aefbb2d50bdca5b
Author: Norman Rasmussen <no...@rasmussen.co.za>
AuthorDate: Fri Dec 31 06:58:44 2021 -0800
Check for too many arguments to hostname
Also use the symbolic value for the success exit code.
---
system/hostname/hostname_main.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/system/hostname/hostname_main.c b/system/hostname/hostname_main.c
index 1c99d56..f56fd46 100644
--- a/system/hostname/hostname_main.c
+++ b/system/hostname/hostname_main.c
@@ -46,6 +46,12 @@ int main(int argc, FAR char *argv[])
if (argc > 1)
{
+ if (argc > 2)
+ {
+ fprintf(stderr, "ERROR: Too many arguments\n");
+ return EXIT_FAILURE;
+ }
+
ret = sethostname(argv[1], strlen(argv[1]));
if (ret != 0)
{
@@ -65,5 +71,5 @@ int main(int argc, FAR char *argv[])
printf("%s\n", hostname);
}
- return 0;
+ return EXIT_SUCCESS;
}