[PATCH] D59116: [scudo][standalone] Implement checksumming functions

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 8 12:37:13 PST 2019


cryptoad added inline comments.


================
Comment at: lib/scudo/standalone/checksum.h:45
+    Sum = static_cast<u16>((Sum >> 1) | ((Sum & 1) << 15));
+    Sum = static_cast<u16>(Sum + (Data & 0xff));
+    Data >>= 8;
----------------
morehouse wrote:
> Are these `static_casts` necessary?
Apparently the result of the operations were promoted (I wouldn't have thought) and lead to the following (with strict W options):
```error: implicit conversion loses integer precision: 'int' to 'scudo::u16' (aka 'unsigned short') [-Werror,-Wimplicit-int-conversion]
error: conversion from 'scudo::uptr' {aka 'long unsigned int'} to 'scudo::u16' {aka 'short unsigned int'} may change value [-Werror=conversion]```


Repository:
  rCRT Compiler Runtime

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59116/new/

https://reviews.llvm.org/D59116





More information about the llvm-commits mailing list