-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from exaexa/mk-ubsan
fix clang ubsan issues
- Loading branch information
Showing
10 changed files
with
39 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* This file is part of scattermore. | ||
* | ||
* Copyright (C) 2022 Mirek Kratochvil <[email protected]> | ||
* Copyright (C) 2022-2023 Mirek Kratochvil <[email protected]> | ||
* 2022-2023 Tereza Kulichova <[email protected]> | ||
* | ||
* scattermore is free software: you can redistribute it and/or modify it under | ||
|
@@ -21,7 +21,15 @@ | |
#ifndef MACROS_H | ||
#define MACROS_H | ||
|
||
#define max(x, y) (((x) >= (y)) ? (x) : (y)) | ||
#define min(x, y) (((x) <= (y)) ? (x) : (y)) | ||
#include <cstddef> | ||
#include <limits> | ||
|
||
inline size_t | ||
f2i(float x) | ||
{ | ||
if (x < 0 || x > float(std::numeric_limits<size_t>::max())) | ||
return std::numeric_limits<size_t>::max(); | ||
return size_t(x); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* This file is part of scattermore. | ||
* | ||
* Copyright (C) 2022 Mirek Kratochvil <[email protected]> | ||
* Copyright (C) 2022-2023 Mirek Kratochvil <[email protected]> | ||
* 2022-2023 Tereza Kulichova <[email protected]> | ||
* | ||
* scattermore is free software: you can redistribute it and/or modify it under | ||
|
@@ -18,9 +18,10 @@ | |
* scattermore. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "macros.h" | ||
#include "scatters.h" | ||
|
||
#include <stddef.h> | ||
#include <cstddef> | ||
|
||
void | ||
scatter_histogram(const unsigned *pn, | ||
|
@@ -42,11 +43,9 @@ scatter_histogram(const unsigned *pn, | |
const float y_end = ylim[0]; | ||
const float y_bin = (size_out_y - 1) / (y_end - y_begin); | ||
|
||
size_t i; | ||
for (i = 0; i < size_data; ++i) { | ||
size_t x = | ||
(xy[i] - x_begin) * x_bin; // get new point coordinates for histogram | ||
size_t y = (xy[i + size_data] - y_begin) * y_bin; | ||
for (size_t i = 0; i < size_data; ++i) { | ||
size_t x = f2i((xy[i] - x_begin) * x_bin); | ||
size_t y = f2i((xy[i + size_data] - y_begin) * y_bin); | ||
|
||
if (x >= size_out_x || y >= size_out_y) | ||
continue; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* This file is part of scattermore. | ||
* | ||
* Copyright (C) 2022 Mirek Kratochvil <[email protected]> | ||
* Copyright (C) 2022-2023 Mirek Kratochvil <[email protected]> | ||
* 2022-2023 Tereza Kulichova <[email protected]> | ||
* | ||
* scattermore is free software: you can redistribute it and/or modify it under | ||
|
@@ -18,9 +18,10 @@ | |
* scattermore. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "macros.h" | ||
#include "scatters.h" | ||
|
||
#include <stddef.h> | ||
#include <cstddef> | ||
|
||
// calculate RGBWT matrix with given color palette and mapping | ||
void | ||
|
@@ -54,9 +55,8 @@ scatter_indexed_rgbwt(const unsigned *dim, | |
|
||
size_t i; | ||
for (i = 0; i < size_data; ++i) { | ||
size_t x = | ||
(xy[i] - x_begin) * x_bin; // get new point coordinates for result raster | ||
size_t y = (xy[i + size_data] - y_begin) * y_bin; | ||
size_t x = f2i((xy[i] - x_begin) * x_bin); | ||
size_t y = f2i((xy[i + size_data] - y_begin) * y_bin); | ||
|
||
if (x >= size_out_x || y >= size_out_y) | ||
continue; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* This file is part of scattermore. | ||
* | ||
* Copyright (C) 2022 Mirek Kratochvil <[email protected]> | ||
* Copyright (C) 2022-2023 Mirek Kratochvil <[email protected]> | ||
* 2022-2023 Tereza Kulichova <[email protected]> | ||
* | ||
* scattermore is free software: you can redistribute it and/or modify it under | ||
|
@@ -18,9 +18,10 @@ | |
* scattermore. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "macros.h" | ||
#include "scatters.h" | ||
|
||
#include <stddef.h> | ||
#include <cstddef> | ||
|
||
// calculate RGBWT matrix with given color for each point | ||
void | ||
|
@@ -53,9 +54,8 @@ scatter_multicolor_rgbwt(const unsigned *dim, | |
|
||
size_t i; | ||
for (i = 0; i < size_data; ++i) { | ||
size_t x = | ||
(xy[i] - x_begin) * x_bin; // get new point coordinates for result raster | ||
size_t y = (xy[i + size_data] - y_begin) * y_bin; | ||
size_t x = f2i((xy[i] - x_begin) * x_bin); | ||
size_t y = f2i((xy[i + size_data] - y_begin) * y_bin); | ||
|
||
if (x >= size_out_x || y >= size_out_y) | ||
continue; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* This file is part of scattermore. | ||
* | ||
* Copyright (C) 2022 Mirek Kratochvil <[email protected]> | ||
* Copyright (C) 2022-2023 Mirek Kratochvil <[email protected]> | ||
* 2022-2023 Tereza Kulichova <[email protected]> | ||
* | ||
* scattermore is free software: you can redistribute it and/or modify it under | ||
|
@@ -18,9 +18,10 @@ | |
* scattermore. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "macros.h" | ||
#include "scatters.h" | ||
|
||
#include <stddef.h> | ||
#include <cstddef> | ||
|
||
// calculate RGBWT matrix with one given color | ||
void | ||
|
@@ -57,9 +58,8 @@ scatter_singlecolor_rgbwt(const unsigned *dim, | |
|
||
size_t i; | ||
for (i = 0; i < size_data; ++i) { | ||
size_t x = | ||
(xy[i] - x_begin) * x_bin; // get new point coordinates for result raster | ||
size_t y = (xy[i + size_data] - y_begin) * y_bin; | ||
size_t x = f2i((xy[i] - x_begin) * x_bin); | ||
size_t y = f2i((xy[i + size_data] - y_begin) * y_bin); | ||
|
||
if (x >= size_out_x || y >= size_out_y) | ||
continue; | ||
|