Bitwise OR instead of logical one in test_aio.c
Thread notes
1 note#refactor
hackorum-bot#refactor
@global #refactor
Hi hackers,
I've noticed an odd check in test_aio.c:
if (zero_on_error | zero_damaged_pages)
srb_flags |= READ_BUFFERS_ZERO_ON_ERROR;
Both zero_on_error and zero_damaged_pages declared as bool. Shouldn't
there be a logical "||" inside the if-condition, not a bitwise "|"?
Yes, it works now, but fixing it would be cleaner.
Proposed patch is attached (although it's quite trivial).
--
best regards,
Mikhail A. Gribkov
On Nov 26, 2026, at 05:02, Mikhail Gribkov <youzhick@gmail.com> wrote:
Hi hackers,
I've noticed an odd check in test_aio.c:
if (zero_on_error | zero_damaged_pages)
srb_flags |= READ_BUFFERS_ZERO_ON_ERROR;Both zero_on_error and zero_damaged_pages declared as bool. Shouldn't there be a logical "||" inside the if-condition, not a bitwise "|"?
Yes, it works now, but fixing it would be cleaner.
For two boolean variables “a" and “b", "a | b" and "a || b" will produce the same result, so there is no correctness issue. But I agree fixing that improves readability.
Proposed patch is attached (although it's quite trivial).
--
best regards,
Mikhail A. Gribkov<001_Fix_bitwise_operation_on_bools.patch>
LGTM.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
Hi Mikhail,
On Thu, Nov 26, 2026 at 5:02 AM Mikhail Gribkov <youzhick@gmail.com> wrote:
Hi hackers,
I've noticed an odd check in test_aio.c:
if (zero_on_error | zero_damaged_pages)
srb_flags |= READ_BUFFERS_ZERO_ON_ERROR;Both zero_on_error and zero_damaged_pages declared as bool. Shouldn't there be a logical "||" inside the if-condition, not a bitwise "|"?
Yes, it works now, but fixing it would be cleaner.Proposed patch is attached (although it's quite trivial).
AI found another one in FuncnameGetCandidates() in namespace.c:
Assert(nargs >= 0 || !(expand_variadic | expand_defaults));
I think they belong to the same category and could be addressed together.
--
Regards,
Xuneng Zhou
HighGo Software Co., Ltd.
AI found another one in FuncnameGetCandidates() in namespace.c:
Assert(nargs >= 0 || !(expand_variadic | expand_defaults));
I think they belong to the same category and could be addressed together.
Whoa, this one is 18 years old!
Yes, I agree these should be addressed together. Neither issue is truly
problematic, but cleaning up the code would be nice.
Attached is the V2-patch fixing both places.
--
best regards,
Mikhail A. Gribkov
On Thu, Nov 26, 2026 at 4:39 AM Xuneng Zhou <xunengzhou@gmail.com> wrote:
Show quoted text
Hi Mikhail,
On Thu, Nov 26, 2026 at 5:02 AM Mikhail Gribkov <youzhick@gmail.com>
wrote:Hi hackers,
I've noticed an odd check in test_aio.c:
if (zero_on_error | zero_damaged_pages)
srb_flags |= READ_BUFFERS_ZERO_ON_ERROR;Both zero_on_error and zero_damaged_pages declared as bool. Shouldn't
there be a logical "||" inside the if-condition, not a bitwise "|"?
Yes, it works now, but fixing it would be cleaner.
Proposed patch is attached (although it's quite trivial).
AI found another one in FuncnameGetCandidates() in namespace.c:
Assert(nargs >= 0 || !(expand_variadic | expand_defaults));
I think they belong to the same category and could be addressed together.
--
Regards,
Xuneng Zhou
HighGo Software Co., Ltd.
On 26/11/2026 09:53, Mikhail Gribkov wrote:
AI found another one in FuncnameGetCandidates() in namespace.c:
Assert(nargs >= 0 || !(expand_variadic | expand_defaults));
I think they belong to the same category and could be addressed together.
Whoa, this one is 18 years old!
Yes, I agree these should be addressed together. Neither issue is truly
problematic, but cleaning up the code would be nice.
Attached is the V2-patch fixing both places.
Committed, thanks.
- Heikki