Skip to content

Commit

Permalink
Removed non-macro use of tertiary operator.
Browse files Browse the repository at this point in the history
  • Loading branch information
lovasko committed May 21, 2019
1 parent fda3808 commit 667c544
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/common/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ append(char* out, const char* inp, const size_t cur, const size_t max)
// Compute string lengths.
rem = max - cur;
len = strlen(inp);
act = len > rem ? rem : len;
if (len > rem) {
act = rem;
} else {
act = len;
}

// Copy the input string.
(void)strncpy(out + cur, inp, act);
Expand Down
19 changes: 17 additions & 2 deletions src/ureq/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,11 +613,26 @@ parse_config(struct config* cf, int argc, char* argv[])
void
log_config(const struct config* cf)
{
const char* bin;
const char* mono;

if (cf->cf_mono == true) {
mono = "yes";
} else {
mono = "no";
}

if (cf->cf_bin == true) {
bin = "yes";
} else {
bin = "no";
}

log(LL_DEBUG, false, "responder UDP port: %" PRIu64, cf->cf_port);
log(LL_DEBUG, false, "unique key: %" PRIu64, cf->cf_key);
log(LL_DEBUG, false, "Time-To-Live: %" PRIu64, cf->cf_ttl);
log(LL_DEBUG, false, "receive buffer size: %" PRIu64 " bytes", cf->cf_rbuf);
log(LL_DEBUG, false, "send buffer size: %" PRIu64 " bytes", cf->cf_sbuf);
log(LL_DEBUG, false, "monologue mode: %s", cf->cf_mono == true ? "yes" : "no");
log(LL_DEBUG, false, "binary report: %s", cf->cf_bin == true ? "yes" : "no");
log(LL_DEBUG, false, "monologue mode: %s", mono);
log(LL_DEBUG, false, "binary report: %s", bin);
}
12 changes: 10 additions & 2 deletions src/ureq/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ resolve_name(struct target* tg,
uint8_t lvl;

// Prepare the logging level for network-related errors.
lvl = cf->cf_err == true ? LL_WARN : LL_DEBUG;
if (cf->cf_err == true) {
lvl = LL_WARN;
} else {
lvl = LL_DEBUG;
}

// Prepare the look-up settings.
(void)memset(&hint, 0, sizeof(hint));
Expand Down Expand Up @@ -281,7 +285,11 @@ load_targets(struct target* tg,
uint64_t tall;

// Prepare the logging level for network-related errors.
lvl = cf->cf_err == true ? LL_WARN : LL_DEBUG;
if (cf->cf_err == true) {
lvl = LL_WARN;
} else {
lvl = LL_DEBUG;
}

// Traverse all targets listed in the configuration.
tall = 0;
Expand Down
19 changes: 17 additions & 2 deletions src/ures/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,26 @@ parse_config(struct config* cf, int argc, char* argv[])
void
log_config(const struct config* cf)
{
const char* mono;
const char* bin;

if (cf->cf_mono == true) {
mono = "yes";
} else {
mono = "no";
}

if (cf->cf_bin == true) {
bin = "yes";
} else {
bin = "no";
}

log(LL_DEBUG, false, "UDP port: %" PRIu64, cf->cf_port);
log(LL_DEBUG, false, "unique key: %" PRIu64, cf->cf_key);
log(LL_DEBUG, false, "Time-To-Live: %" PRIu64, cf->cf_ttl);
log(LL_DEBUG, false, "receive buffer size: %" PRIu64 " bytes", cf->cf_rbuf);
log(LL_DEBUG, false, "send buffer size: %" PRIu64 " bytes", cf->cf_sbuf);
log(LL_DEBUG, false, "monologue mode: %s", cf->cf_mono == true ? "yes" : "no");
log(LL_DEBUG, false, "binary report: %s", cf->cf_bin == true ? "yes" : "no");
log(LL_DEBUG, false, "monologue mode: %s", mono);
log(LL_DEBUG, false, "binary report: %s", bin);
}

0 comments on commit 667c544

Please sign in to comment.