Cleanup: Clang-Tidy readability-redundant-preprocessor fixes

Remove redundantly nested `#if` and `#ifdef` statements.

One nested `#if 0` block was left untouched, as it's in particle code
that's no longer maintained. Furthermore, that block also has some
explanation as to the differences between the enabled & disabled parts.

One nested `#if 0` construct was completely removed, leaving only the
actually used bit of code. There was no explanation as to the usefulness
of the disabled code, and it hasn't been touched in years.

No functional changes.
This commit is contained in:
Sybren A. Stüvel 2020-09-04 11:26:26 +02:00
parent aa4cf47e40
commit 371ddda4d0
6 changed files with 32 additions and 55 deletions

View File

@ -13,7 +13,6 @@ Checks: >
-readability-misleading-indentation,
-readability-inconsistent-declaration-parameter-name,
-readability-redundant-preprocessor,
-readability-redundant-member-init,
-readability-const-return-type,
-readability-static-accessed-through-instance,

View File

@ -102,11 +102,9 @@ Mesh *BKE_mesh_remesh_voxel_ovdb_volume_to_mesh_nomain(struct OpenVDBLevelSet *l
double adaptivity,
bool relax_disoriented_triangles)
{
# ifdef WITH_OPENVDB
struct OpenVDBVolumeToMeshData output_mesh;
OpenVDBLevelSet_volume_to_mesh(
level_set, &output_mesh, isovalue, adaptivity, relax_disoriented_triangles);
# endif
Mesh *mesh = BKE_mesh_new_nomain(output_mesh.totvertices,
0,

View File

@ -64,10 +64,8 @@ static vector<OpenCLDevice *> g_gpudevices;
/// \brief list of all thread for every GPUDevice in cpudevices a thread exists
static ListBase g_gputhreads;
/// \brief all scheduled work for the gpu
# ifdef COM_OPENCL_ENABLED
static bool g_openclActive = false;
static bool g_openclInitialized = false;
# endif
# endif
#endif

View File

@ -483,22 +483,20 @@ static void vicon_gplayer_color_draw(Icon *icon, int x, int y, int w, int h)
immUnbindProgram();
}
# ifndef WITH_HEADLESS
static void init_brush_icons(void)
{
# define INIT_BRUSH_ICON(icon_id, name) \
{ \
uchar *rect = (uchar *)datatoc_##name##_png; \
const int size = datatoc_##name##_png_size; \
DrawInfo *di; \
# define INIT_BRUSH_ICON(icon_id, name) \
{ \
uchar *rect = (uchar *)datatoc_##name##_png; \
const int size = datatoc_##name##_png_size; \
DrawInfo *di; \
\
di = def_internal_icon(NULL, icon_id, 0, 0, w, ICON_TYPE_BUFFER, 0); \
di->data.buffer.image->datatoc_rect = rect; \
di->data.buffer.image->datatoc_size = size; \
} \
((void)0)
di = def_internal_icon(NULL, icon_id, 0, 0, w, ICON_TYPE_BUFFER, 0); \
di->data.buffer.image->datatoc_rect = rect; \
di->data.buffer.image->datatoc_size = size; \
} \
((void)0)
/* end INIT_BRUSH_ICON */
const int w = 96; /* warning, brush size hardcoded in C, but it gets scaled */
@ -556,7 +554,7 @@ static void init_brush_icons(void)
INIT_BRUSH_ICON(ICON_GPBRUSH_ERASE_HARD, gp_brush_erase_hard);
INIT_BRUSH_ICON(ICON_GPBRUSH_ERASE_STROKE, gp_brush_erase_stroke);
# undef INIT_BRUSH_ICON
# undef INIT_BRUSH_ICON
}
static DrawInfo *g_di_event_list = NULL;
@ -630,16 +628,16 @@ static void init_event_icons(void)
{
DrawInfo *di_next = NULL;
# define INIT_EVENT_ICON(icon_id, type, value) \
{ \
DrawInfo *di = def_internal_icon(NULL, icon_id, 0, 0, w, ICON_TYPE_EVENT, 0); \
di->data.input.event_type = type; \
di->data.input.event_value = value; \
di->data.input.icon = icon_id; \
di->data.input.next = di_next; \
di_next = di; \
} \
((void)0)
# define INIT_EVENT_ICON(icon_id, type, value) \
{ \
DrawInfo *di = def_internal_icon(NULL, icon_id, 0, 0, w, ICON_TYPE_EVENT, 0); \
di->data.input.event_type = type; \
di->data.input.event_value = value; \
di->data.input.icon = icon_id; \
di->data.input.next = di_next; \
di_next = di; \
} \
((void)0)
/* end INIT_EVENT_ICON */
const int w = 16; /* DUMMY */
@ -695,7 +693,7 @@ static void init_event_icons(void)
g_di_event_list = di_next;
# undef INIT_EVENT_ICON
# undef INIT_EVENT_ICON
}
static void icon_verify_datatoc(IconImage *iimg)
@ -906,7 +904,7 @@ static void init_internal_icons(void)
{
int x, y;
# if 0 // temp disabled
# if 0 // temp disabled
if ((btheme != NULL) && btheme->tui.iconfile[0]) {
char *icondir = BKE_appdir_folder_id(BLENDER_DATAFILES, "icons");
char iconfilestr[FILE_MAX];
@ -931,7 +929,7 @@ static void init_internal_icons(void)
printf("%s: 'icons' data path not found, continuing\n", __func__);
}
}
# endif
# endif
/* Define icons. */
for (y = 0; y < ICON_GRID_ROWS; y++) {
@ -987,7 +985,6 @@ static void init_internal_icons(void)
def_internal_vicon(ICON_COLORSET_19_VEC, vicon_colorset_draw_19);
def_internal_vicon(ICON_COLORSET_20_VEC, vicon_colorset_draw_20);
}
# endif /* WITH_HEADLESS */
static void init_iconfile_list(struct ListBase *list)
{

View File

@ -3776,6 +3776,7 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance)
#else
/* translate (not rotate) the rest of the hair if its not selected */
{
/* NOLINTNEXTLINE: readability-redundant-preprocessor */
# if 0 /* kindof works but looks worse then what's below */
/* Move the unselected point on a vector based on the

View File

@ -43,29 +43,13 @@
/* Utils */
#if 0
# define param_assert(condition)
# define param_warning(message)
# define param_test_equals_ptr(condition)
# define param_test_equals_int(condition)
#else
# define param_assert(condition) \
if (!(condition)) { /*printf("Assertion %s:%d\n", __FILE__, __LINE__); abort();*/ \
} \
(void)0
# define param_warning(message) \
{/*printf("Warning %s:%d: %s\n", __FILE__, __LINE__, message);*/}(void)0
# if 0
# define param_test_equals_ptr(str, a, b) \
if (a != b) { /*printf("Equals %s => %p != %p\n", str, a, b);*/ \
} \
(void)0
# define param_test_equals_int(str, a, b) \
if (a != b) { /*printf("Equals %s => %d != %d\n", str, a, b);*/ \
} \
(void)0
# endif
#endif
#define param_assert(condition) \
if (!(condition)) { /*printf("Assertion %s:%d\n", __FILE__, __LINE__); abort();*/ \
} \
(void)0
#define param_warning(message) \
{/*printf("Warning %s:%d: %s\n", __FILE__, __LINE__, message);*/}(void)0
typedef enum PBool {
P_TRUE = 1,
P_FALSE = 0,