code cleanup: compile with clang and quiet some warnings.

This commit is contained in:
Campbell Barton
2012-06-28 12:32:06 +00:00
parent 57b69abe0d
commit c8c743b609
12 changed files with 52 additions and 34 deletions

View File

@@ -236,8 +236,7 @@ macro(setup_liblinks
${OPENGL_glu_LIBRARY}
${PNG_LIBRARIES}
${ZLIB_LIBRARIES}
${FREETYPE_LIBRARY}
${LAPACK_LIBRARIES})
${FREETYPE_LIBRARY})
# since we are using the local libs for python when compiling msvc projects, we need to add _d when compiling debug versions
if(WITH_PYTHON) # AND NOT WITH_PYTHON_MODULE # WIN32 needs
@@ -346,7 +345,9 @@ macro(setup_liblinks
if(WITH_INPUT_NDOF)
target_link_libraries(${target} ${NDOF_LIBRARIES})
endif()
if(WITH_MOD_CLOTH_ELTOPO)
target_link_libraries(${target} ${LAPACK_LIBRARIES})
endif()
if(WIN32 AND NOT UNIX)
target_link_libraries(${target} ${PTHREADS_LIBRARIES})
endif()
@@ -452,6 +453,12 @@ macro(remove_strict_flags)
add_cc_flag("${CC_REMOVE_STRICT_FLAGS}")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
remove_cc_flag("-Wunused-parameter")
remove_cc_flag("-Wunused-variable")
remove_cc_flag("-Werror")
endif()
if(MSVC)
# TODO
endif()

View File

@@ -29,33 +29,33 @@
#include "../MEM_guardedalloc.h"
/* not default but can be used when needing to set a string */
void *operator new(size_t size, const char *str)
void *operator new(size_t size, const char *str) throw(std::bad_alloc)
{
return MEM_mallocN(size, str);
}
void *operator new[](size_t size, const char *str)
void *operator new[](size_t size, const char *str) throw(std::bad_alloc)
{
return MEM_mallocN(size, str);
}
void *operator new(size_t size)
void *operator new(size_t size) throw(std::bad_alloc)
{
return MEM_mallocN(size, "C++/anonymous");
}
void *operator new[](size_t size)
void *operator new[](size_t size) throw(std::bad_alloc)
{
return MEM_mallocN(size, "C++/anonymous[]");
}
void operator delete(void *p)
void operator delete(void *p) throw()
{
/* delete NULL is valid in c++ */
if (p)
MEM_freeN(p);
}
void operator delete[](void *p)
void operator delete[](void *p) throw()
{
/* delete NULL is valid in c++ */
if (p)

View File

@@ -50,12 +50,12 @@ private:
/**
* @brief datatype of this MemoryProxy
*/
DataType m_datatype;
/* DataType m_datatype; */ /* UNUSED */
/**
* @brief channel information of this buffer
*/
ChannelInfo m_channelInfo[COM_NUMBER_OF_CHANNELS];
/* ChannelInfo m_channelInfo[COM_NUMBER_OF_CHANNELS]; */ /* UNUSED */
/**
* @brief the allocated memory

View File

@@ -27,8 +27,9 @@ extern "C" {
#include "RE_pipeline.h"
}
BlurBaseOperation::BlurBaseOperation(DataType data_type=COM_DT_COLOR) : NodeOperation()
BlurBaseOperation::BlurBaseOperation(DataType data_type) : NodeOperation()
{
/* data_type is almost always COM_DT_COLOR except for alpha-blur */
this->addInputSocket(data_type);
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(data_type);

View File

@@ -32,7 +32,7 @@ class ChannelMatteOperation : public NodeOperation {
private:
SocketReader *m_inputImageProgram;
int m_color_space; /* node->custom1 */
/* int m_color_space; */ /* node->custom1 */ /* UNUSED */ /* TODO ? */
int m_matte_channel; /* node->custom2 */
int m_limit_method; /* node->algorithm */
int m_limit_channel; /* node->channel */

View File

@@ -1346,7 +1346,7 @@ void UI_view2d_multi_grid_draw(View2D *v2d, float step, int level_size, int totl
glBegin(GL_LINES);
for (; start < v2d->cur.xmax; start += lstep, ++i) {
if (i == 0 || (level < totlevels-1 && i % level_size == 0))
if (i == 0 || (level < totlevels - 1 && i % level_size == 0))
continue;
glVertex2f(start, v2d->cur.ymin);
glVertex2f(start, v2d->cur.ymax);
@@ -1356,14 +1356,14 @@ void UI_view2d_multi_grid_draw(View2D *v2d, float step, int level_size, int totl
start = i * lstep;
for (; start < v2d->cur.ymax; start += lstep, ++i) {
if (i == 0 || (level < totlevels-1 && i % level_size == 0))
if (i == 0 || (level < totlevels - 1 && i % level_size == 0))
continue;
glVertex2f(v2d->cur.xmin, start);
glVertex2f(v2d->cur.xmax, start);
}
/* X and Y axis */
UI_ThemeColorShade(TH_BACK, offset-8);
UI_ThemeColorShade(TH_BACK, offset - 8);
glVertex2f(0.0f, v2d->cur.ymin);
glVertex2f(0.0f, v2d->cur.ymax);
glVertex2f(v2d->cur.xmin, 0.0f);

View File

@@ -51,6 +51,13 @@
# define __func__ __FUNCTION__
#endif
/* copied from BKE_utildefines.h ugh */
#ifdef __GNUC__
# define UNUSED(x) UNUSED_ ## x __attribute__((__unused__))
#else
# define UNUSED(x) x
#endif
/* Replace if different */
#define TMP_EXT ".tmp"
@@ -310,7 +317,7 @@ static void rna_print_data_get(FILE *f, PropertyDefRNA *dp)
fprintf(f, " %s *data= (%s*)(ptr->data);\n", dp->dnastructname, dp->dnastructname);
}
static void rna_print_id_get(FILE *f, PropertyDefRNA *dp)
static void rna_print_id_get(FILE *f, PropertyDefRNA *UNUSED(dp))
{
fprintf(f, " ID *id= ptr->id.data;\n");
}
@@ -1179,7 +1186,7 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property
return func;
}
static char *rna_def_property_next_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp,
static char *rna_def_property_next_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *UNUSED(dp),
const char *manualfunc)
{
char *func, *getfunc;
@@ -1206,7 +1213,7 @@ static char *rna_def_property_next_func(FILE *f, StructRNA *srna, PropertyRNA *p
return func;
}
static char *rna_def_property_end_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp,
static char *rna_def_property_end_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *UNUSED(dp),
const char *manualfunc)
{
char *func;
@@ -2006,7 +2013,7 @@ static void rna_generate_blender(BlenderRNA *brna, FILE *f)
fprintf(f, "};\n\n");
}
static void rna_generate_property_prototypes(BlenderRNA *brna, StructRNA *srna, FILE *f)
static void rna_generate_property_prototypes(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE *f)
{
PropertyRNA *prop;
StructRNA *base;
@@ -2029,7 +2036,7 @@ static void rna_generate_property_prototypes(BlenderRNA *brna, StructRNA *srna,
fprintf(f, "\n");
}
static void rna_generate_parameter_prototypes(BlenderRNA *brna, StructRNA *srna, FunctionRNA *func, FILE *f)
static void rna_generate_parameter_prototypes(BlenderRNA *UNUSED(brna), StructRNA *srna, FunctionRNA *func, FILE *f)
{
PropertyRNA *parm;
@@ -2068,7 +2075,7 @@ static void rna_generate_function_prototypes(BlenderRNA *brna, StructRNA *srna,
fprintf(f, "\n");
}
static void rna_generate_static_parameter_prototypes(BlenderRNA *brna, StructRNA *srna, FunctionDefRNA *dfunc, FILE *f)
static void rna_generate_static_parameter_prototypes(BlenderRNA *UNUSED(brna), StructRNA *srna, FunctionDefRNA *dfunc, FILE *f)
{
FunctionRNA *func;
PropertyDefRNA *dparm;
@@ -2483,7 +2490,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
}
}
static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f)
static void rna_generate_struct(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE *f)
{
FunctionRNA *func;
FunctionDefRNA *dfunc;
@@ -2761,7 +2768,7 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const
}
}
static void rna_generate_header(BlenderRNA *brna, FILE *f)
static void rna_generate_header(BlenderRNA *UNUSED(brna), FILE *f)
{
StructDefRNA *ds;
PropertyDefRNA *dp;
@@ -2929,7 +2936,7 @@ static const char *cpp_classes = ""
"};\n"
"\n";
static void rna_generate_header_cpp(BlenderRNA *brna, FILE *f)
static void rna_generate_header_cpp(BlenderRNA *UNUSED(brna), FILE *f)
{
StructDefRNA *ds;
PropertyDefRNA *dp;

View File

@@ -497,6 +497,9 @@ void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *ext)
ext->free(ext->data); /* decref's the PyObject that the srna owns */
RNA_struct_blender_type_set(srna, NULL); /* this gets accessed again - XXX fixme */
RNA_struct_py_type_set(srna, NULL); /* NULL the srna's value so RNA_struct_free wont complain of a leak */
#else
(void)srna;
(void)ext;
#endif
}

View File

@@ -736,7 +736,7 @@ static void rna_ImageFormatSettings_file_format_set(PointerRNA *ptr, int value)
}
static EnumPropertyItem *rna_ImageFormatSettings_file_format_itemf(bContext *C, PointerRNA *ptr,
PropertyRNA *UNUSED(prop), int *free)
PropertyRNA *UNUSED(prop), int *UNUSED(free))
{
ID *id = ptr->id.data;
if (id && GS(id->name) == ID_SCE) {

View File

@@ -231,7 +231,7 @@ static void rna_Sensor_level_set(struct PointerRNA *ptr, int value)
sens->tap = 0;
}
static void rna_Sensor_Armature_update(Main *bmain, Scene *scene, PointerRNA *ptr)
static void rna_Sensor_Armature_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
bSensor *sens = (bSensor *)ptr->data;
bArmatureSensor *as = sens->data;

View File

@@ -99,7 +99,7 @@ static Sequence *alloc_generic_sequence(Editing *ed, const char *name, int start
return seq;
}
static Sequence *rna_Sequences_new_clip(ID *id, Editing *ed, ReportList *reports,
static Sequence *rna_Sequences_new_clip(ID *id, Editing *ed,
const char *name, MovieClip *clip, int channel,
int start_frame)
{
@@ -118,7 +118,7 @@ static Sequence *rna_Sequences_new_clip(ID *id, Editing *ed, ReportList *reports
return seq;
}
static Sequence *rna_Sequences_new_mask(ID *id, Editing *ed, ReportList *reports,
static Sequence *rna_Sequences_new_mask(ID *id, Editing *ed,
const char *name, Mask *mask, int channel,
int start_frame)
{
@@ -137,7 +137,7 @@ static Sequence *rna_Sequences_new_mask(ID *id, Editing *ed, ReportList *reports
return seq;
}
static Sequence *rna_Sequences_new_scene(ID *id, Editing *ed, ReportList *reports,
static Sequence *rna_Sequences_new_scene(ID *id, Editing *ed,
const char *name, Scene *sce_seq, int channel,
int start_frame)
{
@@ -455,7 +455,7 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_struct_ui_text(srna, "Sequences", "Collection of Sequences");
func = RNA_def_function(srna, "new_clip", "rna_Sequences_new_clip");
RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
RNA_def_function_flag(func, FUNC_USE_SELF_ID);
RNA_def_function_ui_description(func, "Add a new movie clip sequence");
parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence");
RNA_def_property_flag(parm, PROP_REQUIRED);
@@ -472,7 +472,7 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "new_mask", "rna_Sequences_new_mask");
RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
RNA_def_function_flag(func, FUNC_USE_SELF_ID);
RNA_def_function_ui_description(func, "Add a new movie clip sequence");
parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence");
RNA_def_property_flag(parm, PROP_REQUIRED);
@@ -489,7 +489,7 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "new_scene", "rna_Sequences_new_scene");
RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
RNA_def_function_flag(func, FUNC_USE_SELF_ID);
RNA_def_function_ui_description(func, "Add a new scene sequence");
parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence");
RNA_def_property_flag(parm, PROP_REQUIRED);

View File

@@ -75,7 +75,7 @@ inline int test_bb_group4(__m128 *bb_group, const Isect *isec)
* Based on Tactical Optimization of Ray/Box Intersection, by Graham Fyffe
* [http://tog.acm.org/resources/RTNews/html/rtnv21n1.html#art9]
*/
static int rayobject_bb_intersect_test(const Isect *isec, const float *_bb)
static inline int rayobject_bb_intersect_test(const Isect *isec, const float *_bb)
{
const float *bb = _bb;