From: Julius Bünger Date: Mon, 25 Jun 2018 11:43:16 +0000 (+0200) Subject: use more proper way to parse cli options X-Git-Tag: v0.11.0~357^2~3^2 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=64e37887ea50a99b2ff4a3991d75dab9ea2a0c49;p=oweals%2Fgnunet.git use more proper way to parse cli options --- 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,