From 2df82a2a2be909e0a1208ed2fe41637f24436414 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 21 Jun 2013 12:33:19 +0000 Subject: [PATCH] Code cleanup: fix some vs2012 compiler warnings --- build_files/cmake/macros.cmake | 10 ++++-- intern/locale/boost_locale_wrapper.cpp | 4 +-- source/blender/blenfont/intern/blf_lang.c | 2 +- source/blender/blenlib/intern/math_geom.c | 2 +- source/blender/blenlib/intern/string.c | 2 +- source/blender/blenlib/intern/winstuff.c | 2 +- source/blender/editors/uvedit/uvedit_ops.c | 6 ++-- source/blender/imbuf/IMB_imbuf_types.h | 18 +++++----- .../imbuf/intern/dds/DirectDrawSurface.cpp | 34 +++++++++---------- .../imbuf/intern/openexr/openexr_api.cpp | 4 +-- .../blender/render/intern/source/initrender.c | 7 ++-- .../blender/render/intern/source/voxeldata.c | 2 +- .../blender/windowmanager/intern/wm_keymap.c | 2 +- .../gameengine/VideoTexture/VideoFFmpeg.cpp | 3 +- 14 files changed, 53 insertions(+), 45 deletions(-) diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index b1dd76fbd14..109d9244b3a 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -401,8 +401,14 @@ macro(TEST_SSE_SUPPORT set(${_sse_flags} "-msse") set(${_sse2_flags} "-msse2") elseif(MSVC) - set(${_sse_flags} "/arch:SSE") - set(${_sse2_flags} "/arch:SSE2") + # x86_64 has this auto enabled + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + set(${_sse_flags} "") + set(${_sse2_flags} "") + else() + set(${_sse_flags} "/arch:SSE") + set(${_sse2_flags} "/arch:SSE2") + endif() elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") set(${_sse_flags} "") # icc defaults to -msse set(${_sse2_flags} "-msse2") diff --git a/intern/locale/boost_locale_wrapper.cpp b/intern/locale/boost_locale_wrapper.cpp index 1b75c74c57b..3492ec05e82 100644 --- a/intern/locale/boost_locale_wrapper.cpp +++ b/intern/locale/boost_locale_wrapper.cpp @@ -113,8 +113,8 @@ const char *bl_locale_pgettext(const char *msgctxt, const char *msgid) return r; return msgid; } - catch(std::exception const &e) { + catch(std::exception const &) { // std::cout << "bl_locale_pgettext(" << msgctxt << ", " << msgid << "): " << e.what() << " \n"; return msgid; } -} \ No newline at end of file +} diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c index 65abfc52ee5..9649e5bc746 100644 --- a/source/blender/blenfont/intern/blf_lang.c +++ b/source/blender/blenfont/intern/blf_lang.c @@ -66,7 +66,7 @@ static void free_locales(void) MEM_freeN((void *)locales_menu[idx].description); /* Also frees locales's relevant value! */ } - MEM_freeN(locales); + MEM_freeN((void *)locales); locales = NULL; } if (locales_menu) { diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index fff5bc52003..a4e7424e5dd 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -3110,7 +3110,7 @@ void accumulate_vertex_normals(float n1[3], float n2[3], float n3[3], /* Add weighted face normal component into normals of the face vertices. * Caller must pass pre-allocated vdiffs of nverts length. */ void accumulate_vertex_normals_poly(float **vertnos, const float polyno[3], - const float **vertcos, float vdiffs[][3], int nverts) + const float **vertcos, float vdiffs[][3], const int nverts) { int i; diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index 9d811aba503..03bed428c07 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -556,7 +556,7 @@ void BLI_timestr(double _time, char *str, size_t maxlen) } /* determine the length of a fixed-size string */ -size_t BLI_strnlen(const char *s, size_t maxlen) +size_t BLI_strnlen(const char *s, const size_t maxlen) { size_t len; diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index ed6b1664ca8..071675c21b9 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -41,7 +41,7 @@ #define WIN32_SKIP_HKEY_PROTECTION // need to use HKEY #include "BLI_winstuff.h" -#include "BLI_utildefines.h"z +#include "BLI_utildefines.h" #include "BLI_path_util.h" #include "BLI_string.h" diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 386eda7dd38..75160cc8a16 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -84,8 +84,8 @@ #include "uvedit_intern.h" static void uv_select_all_perform(Scene *scene, Image *ima, BMEditMesh *em, int action); -static void uv_select_flush_from_tag_face(SpaceImage *sima, Scene *scene, Object *obedit, bool select); -static void uv_select_flush_from_tag_loop(SpaceImage *sima, Scene *scene, Object *obedit, bool select); +static void uv_select_flush_from_tag_face(SpaceImage *sima, Scene *scene, Object *obedit, const bool select); +static void uv_select_flush_from_tag_loop(SpaceImage *sima, Scene *scene, Object *obedit, const bool select); /************************* state testing ************************/ @@ -2694,7 +2694,7 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima, Scene *scene, Object * * \note! This function is very similar to #uv_select_flush_from_tag_loop, be sure to update both upon changing. */ -static void uv_select_flush_from_tag_loop(SpaceImage *sima, Scene *scene, Object *obedit, bool select) +static void uv_select_flush_from_tag_loop(SpaceImage *sima, Scene *scene, Object *obedit, const bool select) { /* Selecting UV Loops with some modes requires us to change * the selection in other faces (depending on the sticky mode). diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index dde8d4d4ab7..1734073dd6c 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -248,24 +248,24 @@ typedef struct ImBuf { /* dds */ #ifdef WITH_DDS -#ifndef MAKEFOURCC -#define MAKEFOURCC(ch0, ch1, ch2, ch3)\ +#ifndef DDS_MAKEFOURCC +#define DDS_MAKEFOURCC(ch0, ch1, ch2, ch3)\ ((unsigned long)(unsigned char)(ch0) | \ ((unsigned long)(unsigned char)(ch1) << 8) | \ ((unsigned long)(unsigned char)(ch2) << 16) | \ ((unsigned long)(unsigned char)(ch3) << 24)) -#endif /* MAKEFOURCC */ +#endif /* DDS_MAKEFOURCC */ /* * FOURCC codes for DX compressed-texture pixel formats */ -#define FOURCC_DDS (MAKEFOURCC('D','D','S',' ')) -#define FOURCC_DXT1 (MAKEFOURCC('D','X','T','1')) -#define FOURCC_DXT2 (MAKEFOURCC('D','X','T','2')) -#define FOURCC_DXT3 (MAKEFOURCC('D','X','T','3')) -#define FOURCC_DXT4 (MAKEFOURCC('D','X','T','4')) -#define FOURCC_DXT5 (MAKEFOURCC('D','X','T','5')) +#define FOURCC_DDS (DDS_MAKEFOURCC('D','D','S',' ')) +#define FOURCC_DXT1 (DDS_MAKEFOURCC('D','X','T','1')) +#define FOURCC_DXT2 (DDS_MAKEFOURCC('D','X','T','2')) +#define FOURCC_DXT3 (DDS_MAKEFOURCC('D','X','T','3')) +#define FOURCC_DXT4 (DDS_MAKEFOURCC('D','X','T','4')) +#define FOURCC_DXT5 (DDS_MAKEFOURCC('D','X','T','5')) #endif /* DDS */ extern const char *imb_ext_image[]; diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp index df15cb3e357..f6606711cc3 100644 --- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp +++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp @@ -65,28 +65,28 @@ /*** declarations ***/ -#if !defined(MAKEFOURCC) -# define MAKEFOURCC(ch0, ch1, ch2, ch3) \ +#if !defined(DDS_MAKEFOURCC) +# define DDS_MAKEFOURCC(ch0, ch1, ch2, ch3) \ (uint(uint8(ch0)) | (uint(uint8(ch1)) << 8) | \ (uint(uint8(ch2)) << 16) | (uint(uint8(ch3)) << 24 )) #endif -static const uint FOURCC_NVTT = MAKEFOURCC('N', 'V', 'T', 'T'); -static const uint FOURCC_DDS = MAKEFOURCC('D', 'D', 'S', ' '); -static const uint FOURCC_DXT1 = MAKEFOURCC('D', 'X', 'T', '1'); -static const uint FOURCC_DXT2 = MAKEFOURCC('D', 'X', 'T', '2'); -static const uint FOURCC_DXT3 = MAKEFOURCC('D', 'X', 'T', '3'); -static const uint FOURCC_DXT4 = MAKEFOURCC('D', 'X', 'T', '4'); -static const uint FOURCC_DXT5 = MAKEFOURCC('D', 'X', 'T', '5'); -static const uint FOURCC_RXGB = MAKEFOURCC('R', 'X', 'G', 'B'); -static const uint FOURCC_ATI1 = MAKEFOURCC('A', 'T', 'I', '1'); -static const uint FOURCC_ATI2 = MAKEFOURCC('A', 'T', 'I', '2'); +static const uint FOURCC_NVTT = DDS_MAKEFOURCC('N', 'V', 'T', 'T'); +static const uint FOURCC_DDS = DDS_MAKEFOURCC('D', 'D', 'S', ' '); +static const uint FOURCC_DXT1 = DDS_MAKEFOURCC('D', 'X', 'T', '1'); +static const uint FOURCC_DXT2 = DDS_MAKEFOURCC('D', 'X', 'T', '2'); +static const uint FOURCC_DXT3 = DDS_MAKEFOURCC('D', 'X', 'T', '3'); +static const uint FOURCC_DXT4 = DDS_MAKEFOURCC('D', 'X', 'T', '4'); +static const uint FOURCC_DXT5 = DDS_MAKEFOURCC('D', 'X', 'T', '5'); +static const uint FOURCC_RXGB = DDS_MAKEFOURCC('R', 'X', 'G', 'B'); +static const uint FOURCC_ATI1 = DDS_MAKEFOURCC('A', 'T', 'I', '1'); +static const uint FOURCC_ATI2 = DDS_MAKEFOURCC('A', 'T', 'I', '2'); -static const uint FOURCC_A2XY = MAKEFOURCC('A', '2', 'X', 'Y'); +static const uint FOURCC_A2XY = DDS_MAKEFOURCC('A', '2', 'X', 'Y'); -static const uint FOURCC_DX10 = MAKEFOURCC('D', 'X', '1', '0'); +static const uint FOURCC_DX10 = DDS_MAKEFOURCC('D', 'X', '1', '0'); -static const uint FOURCC_UVER = MAKEFOURCC('U', 'V', 'E', 'R'); +static const uint FOURCC_UVER = DDS_MAKEFOURCC('U', 'V', 'E', 'R'); // 32 bit RGB formats. static const uint D3DFMT_R8G8B8 = 20; @@ -672,7 +672,7 @@ void DDSHeader::setFourCC(uint8 c0, uint8 c1, uint8 c2, uint8 c3) { // set fourcc pixel format. this->pf.flags = DDPF_FOURCC; - this->pf.fourcc = MAKEFOURCC(c0, c1, c2, c3); + this->pf.fourcc = DDS_MAKEFOURCC(c0, c1, c2, c3); this->pf.bitcount = 0; this->pf.rmask = 0; @@ -696,7 +696,7 @@ void DDSHeader::setFormatCode(uint32 code) void DDSHeader::setSwizzleCode(uint8 c0, uint8 c1, uint8 c2, uint8 c3) { - this->pf.bitcount = MAKEFOURCC(c0, c1, c2, c3); + this->pf.bitcount = DDS_MAKEFOURCC(c0, c1, c2, c3); } diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 8159520f693..6db7cfc8efd 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -640,7 +640,7 @@ void IMB_exrtile_begin_write(void *handle, const char *filename, int mipmap, int data->ofile_stream = new OFileStream(filename); data->tofile = new TiledOutputFile(*(data->ofile_stream), header); } - catch (const std::exception &exc) { + catch (const std::exception &) { delete data->tofile; delete data->ofile_stream; @@ -660,7 +660,7 @@ int IMB_exr_begin_read(void *handle, const char *filename, int *width, int *heig data->ifile_stream = new IFileStream(filename); data->ifile = new InputFile(*(data->ifile_stream)); } - catch (const std::exception &exc) { + catch (const std::exception &) { delete data->ifile; delete data->ifile_stream; diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index 0d957f8019f..d4d4a703d6c 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -268,7 +268,7 @@ void make_sample_tables(Render *re) SampleTables *st; float flweight[32]; float weight[32], totw, val, *fpx1, *fpx2, *fpy1, *fpy2, *m3, *m4; - int i, j, a; + int i, j, a, centmasksize; /* optimization tables, only once */ if (firsttime) { @@ -303,7 +303,8 @@ void make_sample_tables(Render *re) if (a & 128) st->cmask[a]++; } - st->centmask = MEM_mallocN((1 << re->osa), "Initfilt3"); + centmasksize = (1 << re->osa); + st->centmask = MEM_mallocN(centmasksize, "Initfilt3"); for (a = 0; a < 16; a++) { st->centLut[a] = -0.45f + ((float)a) / 16.0f; @@ -425,7 +426,7 @@ void make_sample_tables(Render *re) } } - for (a = (1 << re->osa) - 1; a > 0; a--) { + for (a = centmasksize - 1; a > 0; a--) { val = st->cmask[a & 255] + st->cmask[a >> 8]; i = 8 + (15.9f * (fpy1[a & 255] + fpy2[a >> 8]) / val); CLAMP(i, 0, 15); diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c index 1c76a228566..0aa1bcfef34 100644 --- a/source/blender/render/intern/source/voxeldata.c +++ b/source/blender/render/intern/source/voxeldata.c @@ -224,7 +224,7 @@ static int read_voxeldata_header(FILE *fp, struct VoxelData *vd) return 1; } -static void init_frame_smoke(VoxelData *vd, float cfra) +static void init_frame_smoke(VoxelData *vd, int cfra) { #ifdef WITH_SMOKE Object *ob; diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 4a0e8270bc9..6a2611592f1 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -792,7 +792,7 @@ const char *WM_key_event_string(short type) return ""; } -int WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len) +int WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, const int len) { char buf[128]; diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index be7f9392f39..7b48d47232b 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -584,7 +584,6 @@ void VideoFFmpeg::openCam (char *file, short camIdx) AVInputFormat *inputFormat; AVDictionary *formatParams = NULL; char filename[28], rateStr[20]; - char *p; #ifdef WIN32 // video capture on windows only through Video For Windows driver @@ -608,6 +607,8 @@ void VideoFFmpeg::openCam (char *file, short camIdx) // /dev/ieee1394/1:ntsc // dv1394:secam // v4l:pal + char *p; + if (file && strstr(file, "1394") != NULL) { // the user specifies a driver, check if it is v4l or d41394