refactor: simplify FLAGS condition
This commit is contained in:
parent
79bc8b7424
commit
e7f4caf342
2 changed files with 5 additions and 4 deletions
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "cli.h"
|
||||
#include "internal/cli/messages.h"
|
||||
#include "ping/ft_ping_flags.h"
|
||||
|
||||
/* Map -? to -h to support help shortcut */
|
||||
#define HANDLE_QUESTION_MARK(opt) \
|
||||
|
|
@ -77,15 +78,15 @@ handle_one_option(int opt, char **argv, void *config,
|
|||
|
||||
if ('?' == opt)
|
||||
return error_unknown_opt(current_opt);
|
||||
if (':' == opt)
|
||||
else if (':' == opt)
|
||||
return error_invalid_opt(current_opt);
|
||||
|
||||
desc = find_option_handler(opt, opts, nb_opts);
|
||||
bitmask_index = (size_t)(desc - opts);
|
||||
if (*opt_tracker & (1ULL << bitmask_index))
|
||||
if (HAS_FLAG(*opt_tracker, (1ULL << bitmask_index)))
|
||||
return error_duplicate_opt(current_opt);
|
||||
|
||||
*opt_tracker |= (1ULL << bitmask_index);
|
||||
SET_FLAG(*opt_tracker, (1ULL << bitmask_index));
|
||||
res = desc->handler(optarg, config);
|
||||
if (CLI_SUCCESS != res)
|
||||
return error_invalid_opt(current_opt);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ ping_output_packet(const icmp_reply_t *reply, uint16_t seq,
|
|||
{
|
||||
char from_str[INET_ADDRSTRLEN];
|
||||
|
||||
if (HAS_FLAG(config->flags, FLAG_QUIET) || HAS_FLAG(config->flags, FLAG_FLOOD))
|
||||
if (HAS_FLAG(config->flags, FLAG_QUIET | FLAG_FLOOD))
|
||||
return;
|
||||
inet_ntop(AF_INET, &reply->from, from_str, sizeof(from_str));
|
||||
printf("%zu bytes from %s: icmp_seq=%u ttl=%u time=%.3f ms\n",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue