QMessageLogger: reject negative values for QT_FATAL_xxx
Amends ceb859bf036dfdd1c54eec403006eac62a0d09b8 We'd accept negative values and keep counting downwards, reaching 0 again only after a full underflow[*]. Effectively, this meant that a negative value was the same as zero, so this makes the behavior explicit. The commit introducing checked_var_value() said in its changelog: For compatibility reasons with previous versions, if the variable is set to any non-empty and non-numeric value different from 0, Qt will understand as "stop on first warning". Negative values are not "non-empty and non-numeric", so this commit chooses to make the current behavior explicit. [*] atomic under- and overflows are defined behavior, but only if the atomic operation is the one producing it. The current code is doing the subtraction by itself in the call to testAndSetRelaxed(), so underflows are still UB. If/when this is replaced by atomicMutate, that might change (and note to self when implementing that!). Pick-to: 6.9 6.8 Change-Id: I594ed31f1cc7fc04ea98c6e86bdcaa3a4aa59114 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
6e37cd4176
commit
c8ecd0eb22
@ -146,7 +146,7 @@ static int checked_var_value(const char *varname)
|
||||
|
||||
bool ok;
|
||||
int value = str.toInt(&ok, 0);
|
||||
return ok ? value : 1;
|
||||
return (ok && value >= 0) ? value : 1;
|
||||
}
|
||||
|
||||
static bool is_fatal_count_down(QAtomicInt &n)
|
||||
|
Loading…
x
Reference in New Issue
Block a user