Page MenuHome

clog: fix VS static analysis warnings
AbandonedPublic

Authored by James Fulop (Yam) on Jan 16 2020, 1:06 PM.

Details

Summary

Changes necessary to resolve c26451 warnings in this file. https://docs.microsoft.com/en-us/visualstudio/code-quality/c26451?view=vs-2019

Exact warning messages:

D:\projects\blender\source\intern\clog\clog.c(307): warning C26451: Arithmetic overflow: Using operator '-' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '-' to avoid overflow (io.2).
D:\projects\blender\source\intern\clog\clog.c(308): warning C26451: Arithmetic overflow: Using operator '-' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '-' to avoid overflow (io.2).
D:\projects\blender\source\intern\clog\clog.c(569): warning C26451: Arithmetic overflow: Using operator '+' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '+' to avoid overflow (io.2).

Diff Detail

Repository
rB Blender

Event Timeline

Campbell Barton (campbellbarton) abandoned this revision.EditedJan 17 2020, 4:01 PM

In general these analysis tools should be used as possible advice, but not necessarily treated as problems to fix.

Rejecting since the ranges of values in this case are short strings (a few words at most), where the risk of existing code or future modifications overflowing a 32bit int is lower than wrapping an unsigned value on subtraction.