From 64e37887ea50a99b2ff4a3991d75dab9ea2a0c49 Mon Sep 17 00:00:00 2001 From: Julius Bünger Date: Mon, 25 Jun 2018 13:43:16 +0200 Subject: use more proper way to parse cli options --- src/rps/gnunet-rps.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/rps/gnunet-rps.c b/src/rps/gnunet-rps.c index e09277589..739f71dac 100644 --- a/src/rps/gnunet-rps.c +++ b/src/rps/gnunet-rps.c @@ -155,7 +155,11 @@ run (void *cls, (!view_update)) { /* Request n PeerIDs */ /* If number was specified use it, else request single peer. */ - num_peers = (NULL == args[0]) ? 1 : atoi (args[0]); + if (NULL == args[0] || + 0 == sscanf (args[0], "%lu", &num_peers)) + { + num_peers = 1; + } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting %" PRIu64 " PeerIDs\n", num_peers); req_handle = GNUNET_RPS_request_peers (rps_handle, num_peers, reply_handle, NULL); @@ -163,7 +167,11 @@ run (void *cls, } else if (view_update) { /* Get updates of view */ - num_view_updates = (NULL == args[0]) ? 0 : atoi (args[0]); + if (NULL == args[0] || + 0 == sscanf (args[0], "%lu", &num_view_updates)) + { + num_view_updates = 0; + } GNUNET_RPS_view_request (rps_handle, num_view_updates, view_update_handle, NULL); if (0 != num_view_updates) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, -- cgit v1.2.3