mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Remove three uses of bitwise ops on boolean values.
If values are boolean, it's confusing to use & and | in place of && and ||. In two of these three cases it was simply a typo and I've used the other one; in the third, it was a deliberate avoidance of short- circuit evaluation (and commented as such), but having seen how easy it is to make the same typo by accident, I've decided it's clearer to just move the LHS and RHS evaluations outside the expression.
This commit is contained in:
parent
3a2afbc9c0
commit
5cb56389bd
@ -376,7 +376,7 @@ static void mainchan_send_eof(Channel *chan)
|
||||
mainchan *mc = container_of(chan, mainchan, chan);
|
||||
PacketProtocolLayer *ppl = mc->ppl; /* for ppl_logevent */
|
||||
|
||||
if (!mc->eof_sent & (seat_eof(mc->ppl->seat) || mc->got_pty)) {
|
||||
if (!mc->eof_sent && (seat_eof(mc->ppl->seat) || mc->got_pty)) {
|
||||
/*
|
||||
* Either seat_eof told us that the front end wants us to
|
||||
* close the outgoing side of the connection as soon as we see
|
||||
|
@ -1903,11 +1903,11 @@ static void ssh2_transport_reconfigure(PacketProtocolLayer *ppl, Conf *conf)
|
||||
if (s->max_data_size < old_max_data_size) {
|
||||
unsigned long diff = old_max_data_size - s->max_data_size;
|
||||
|
||||
/* Intentionally use bitwise OR instead of logical, so
|
||||
* that we decrement both counters even if the first one
|
||||
* runs out */
|
||||
if ((DTS_CONSUME(s->stats, out, diff) != 0) |
|
||||
(DTS_CONSUME(s->stats, in, diff) != 0))
|
||||
/* We must decrement both counters, so avoid short-circuit
|
||||
* evaluation skipping one */
|
||||
int out_expired = DTS_CONSUME(s->stats, out, diff) != 0;
|
||||
int in_expired = DTS_CONSUME(s->stats, in, diff) != 0;
|
||||
if (out_expired || in_expired)
|
||||
rekey_reason = "data limit lowered";
|
||||
} else {
|
||||
unsigned long diff = s->max_data_size - old_max_data_size;
|
||||
|
@ -407,7 +407,7 @@ static const char *gtk_askpass_setup(struct askpass_ctx *ctx,
|
||||
ctx->cols[2].red = ctx->cols[2].green = ctx->cols[2].blue = 0x8000;
|
||||
gdk_colormap_alloc_colors(ctx->colmap, ctx->cols, 2,
|
||||
FALSE, TRUE, success);
|
||||
if (!success[0] | !success[1])
|
||||
if (!success[0] || !success[1])
|
||||
return "unable to allocate colours";
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user