Commit 5a72f3cd authored by Albert Astals Cid's avatar Albert Astals Cid

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
parent ff1ab1b0
......@@ -79,7 +79,7 @@ build_clazy:
- 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:
......
......@@ -1826,7 +1826,7 @@ void CairoOutputDev::setSoftMask(GfxState * state, const double * bbox, bool alp
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 @@ void CairoOutputDev::drawMaskedImage(GfxState *state, Object *ref,
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 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s
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 @@ public:
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 {
......
......@@ -279,7 +279,7 @@ bool CairoRescaleBox::downScaleImage(unsigned orig_width, unsigned orig_height,
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));
......
......@@ -1024,7 +1024,7 @@ void ArthurOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
// 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 @@ void ArthurOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
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 @@ void ArthurOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *
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);
......
......@@ -428,7 +428,7 @@ void ImageOutputDev::writeImageFile(ImgWriter *writer, ImageFormat format, const
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);
......
......@@ -469,7 +469,7 @@ static void writePageImage(GooString *filename)
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++) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment