Use reinterpret_cast to silence cast-align warnings
In ImageOutputDev it comes directly from malloc, and malloc guarantees
alignment for basic types, so we're good
In ArthurOutputDev it comes from QImage::bits that uses malloc
internally, so we're good
In cairo* it comes from cairo_image_surface_get_data that comes from
pixman_image_get_data that returns a uint32_t * so we're only going to
the original type alignment
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 55b5d5c..0ee2e20 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -79,7 +79,7 @@
- dnf -y install curl make ninja-build openjpeg2-tools clazy clang redhat-rpm-config
script:
- mkdir -p build && cd build
- - CC=clang CXX=clazy CXXFLAGS="-Werror -Wno-cast-align -Wno-deprecated-declarations" cmake -G Ninja ..
+ - CC=clang CXX=clazy CXXFLAGS="-Werror -Wno-deprecated-declarations" cmake -G Ninja ..
- CLAZY_CHECKS="level0,level1,level2,isempty-vs-count,qhash-with-char-pointer-key,tr-non-literal,no-non-pod-global-static" ninja
build_android:
diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 02a6f26..30c9f57 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1826,7 +1826,7 @@
cairo_destroy(maskCtx);
/* convert to a luminocity map */
- uint32_t *source_data = (uint32_t*)cairo_image_surface_get_data(source);
+ uint32_t *source_data = reinterpret_cast<uint32_t *>(cairo_image_surface_get_data(source));
/* get stride in units of 32 bits */
ptrdiff_t stride = cairo_image_surface_get_stride(source)/4;
for (int y=0; y<height; y++) {
@@ -2594,7 +2594,7 @@
buffer = cairo_image_surface_get_data (image);
row_stride = cairo_image_surface_get_stride (image);
for (y = 0; y < height; y++) {
- dest = (unsigned int *) (buffer + y * row_stride);
+ dest = reinterpret_cast<unsigned int *>(buffer + y * row_stride);
pix = imgStr->getLine();
colorMap->getRGBLine (pix, dest, width);
}
@@ -2746,7 +2746,7 @@
buffer = cairo_image_surface_get_data (image);
row_stride = cairo_image_surface_get_stride (image);
for (y = 0; y < height; y++) {
- dest = (unsigned int *) (buffer + y * row_stride);
+ dest = reinterpret_cast<unsigned int *>(buffer + y * row_stride);
pix = imgStr->getLine();
colorMap->getRGBLine (pix, dest, width);
}
@@ -3154,7 +3154,7 @@
buffer = cairo_image_surface_get_data (image);
stride = cairo_image_surface_get_stride (image);
for (int y = 0; y < height; y++) {
- uint32_t *dest = (uint32_t *) (buffer + y * stride);
+ uint32_t *dest = reinterpret_cast<uint32_t *>(buffer + y * stride);
getRow(y, dest);
}
} else {
diff --git a/poppler/CairoRescaleBox.cc b/poppler/CairoRescaleBox.cc
index 7f375a8..838d634 100644
--- a/poppler/CairoRescaleBox.cc
+++ b/poppler/CairoRescaleBox.cc
@@ -279,7 +279,7 @@
unsigned int *dest;
int dst_stride;
- dest = (unsigned int *)cairo_image_surface_get_data (dest_surface);
+ dest = reinterpret_cast<unsigned int *>(cairo_image_surface_get_data (dest_surface));
dst_stride = cairo_image_surface_get_stride (dest_surface);
scanline = (uint32_t*)gmallocn (orig_width, sizeof(int));
diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/ArthurOutputDev.cc
index 750dc1d..deb4451 100644
--- a/qt5/src/ArthurOutputDev.cc
+++ b/qt5/src/ArthurOutputDev.cc
@@ -1024,7 +1024,7 @@
// TODO: Would using QImage::Format_Mono be more efficient here?
QImage image(width, height, QImage::Format_ARGB32);
- unsigned int *data = (unsigned int *)image.bits();
+ unsigned int *data = reinterpret_cast<unsigned int *>(image.bits());
int stride = image.bytesPerLine()/4;
QRgb fillColor = m_currentBrush.color().rgb();
@@ -1074,7 +1074,7 @@
imgStr->reset();
image = QImage(width, height, QImage::Format_ARGB32);
- data = (unsigned int *)image.bits();
+ data = reinterpret_cast<unsigned int *>(image.bits());
stride = image.bytesPerLine()/4;
for (y = 0; y < height; y++) {
pix = imgStr->getLine();
@@ -1149,7 +1149,7 @@
maskImageStr->reset();
QImage image(width, height, QImage::Format_ARGB32);
- unsigned int *data = (unsigned int *)image.bits();
+ unsigned int *data = reinterpret_cast<unsigned int *>(image.bits());
int stride = image.bytesPerLine()/4;
std::vector<unsigned char> maskLine(maskWidth);
diff --git a/utils/ImageOutputDev.cc b/utils/ImageOutputDev.cc
index 8390407..1671938 100644
--- a/utils/ImageOutputDev.cc
+++ b/utils/ImageOutputDev.cc
@@ -428,7 +428,7 @@
case imgRGB48: {
p = imgStr->getLine();
- unsigned short *rowp16 = (unsigned short*)row;
+ unsigned short *rowp16 = reinterpret_cast<unsigned short*>(row);
for (int x = 0; x < width; ++x) {
if (p) {
colorMap->getRGB(p, &rgb);
diff --git a/utils/pdftocairo.cc b/utils/pdftocairo.cc
index 614cd0b..e6d22f3 100644
--- a/utils/pdftocairo.cc
+++ b/utils/pdftocairo.cc
@@ -469,7 +469,7 @@
unsigned char *row = (unsigned char *) gmallocn(width, 4);
for (int y = 0; y < height; y++ ) {
- uint32_t *pixel = (uint32_t *) (data + y*stride);
+ uint32_t *pixel = reinterpret_cast<uint32_t *>((data + y*stride));
unsigned char *rowp = row;
int bit = 7;
for (int x = 0; x < width; x++, pixel++) {