Patch [#33196] Warning Fixes 11-16-2012

* MEM_CacheLimitier - Size type to int conversion, should be safe for now (doing my best Bill Gates 640k impression)
* OpenNL CMakeLists.txt - MSVC and GCC have slightly different ways to remove definitions (DEBUG) without the compiler complaining
* BLI_math inlines - The include guard name and inline option macro name should be different. Suppressed warning about not exporting any symbols from inline math library
* BLI string / utf8 - Fixed some inconsistencies between declarations and definitions
* nodes - node_composite_util is apparently not used unless you enable the legacy compositor, so it should not be compiled in that case.

Leaving out changes to BLI_fileops for now, need to do more testing.
This commit is contained in:
Jason Wilkins 2012-11-23 15:12:13 +00:00
parent c407c951a0
commit 69b88cf719
14 changed files with 51 additions and 34 deletions

View File

@ -247,8 +247,10 @@ private:
if (!elem->can_destroy())
continue;
/* by default 0 means higherst priority element */
int priority = -(queue.size() - i - 1);
/* by default 0 means highest priority element */
/* casting a size type to int is questionable,
but unlikely to cause problems */
int priority = -((int)(queue.size()) - i - 1);
priority = getItemPriority(elem->get()->get_data(), priority);
if (priority < best_match_priority || best_match_elem == NULL) {

View File

@ -28,7 +28,11 @@ remove_strict_flags()
# remove debug flag here since this is not a blender maintained library
# and debug gives a lot of prints on UV unwrapping. developers can enable if they need to.
add_definitions(-UDEBUG)
if(MSVC)
remove_definitions(-DDEBUG)
else()
add_definitions(-UDEBUG)
endif()
# quiet compiler warnings about undefined defines

View File

@ -170,7 +170,7 @@
} (void)0
#endif
#ifdef __BLI_MATH_INLINE_H__
#if BLI_MATH_DO_INLINE
#include "intern/math_base_inline.c"
#endif
@ -203,7 +203,7 @@ MINLINE int is_power_of_2_i(int n);
MINLINE int power_of_2_max_i(int n);
MINLINE int power_of_2_min_i(int n);
MINLINE float shell_angle_to_dist(float angle);
MINLINE float shell_angle_to_dist(const float angle);
#if (defined(WIN32) || defined(WIN64)) && !defined(FREE_WINDOWS)
extern double copysign(double x, double y);

View File

@ -121,7 +121,7 @@ MINLINE int compare_rgb_uchar(const unsigned char a[3], const unsigned char b[3]
void lift_gamma_gain_to_asc_cdl(float *lift, float *gamma, float *gain, float *offset, float *slope, float *power);
#ifdef __BLI_MATH_INLINE_H__
#if BLI_MATH_DO_INLINE
#include "intern/math_color_inline.c"
#endif

View File

@ -36,7 +36,7 @@ extern "C" {
#include "BLI_math_inline.h"
#ifdef __BLI_MATH_INLINE_H__
#if BLI_MATH_DO_INLINE
#include "intern/math_geom_inline.c"
#endif

View File

@ -35,9 +35,10 @@ extern "C" {
#endif
/* add platform/compiler checks here if it is not supported */
#define __BLI_MATH_INLINE_H__
/* all platforms support forcing inline so this is always enabled */
#define BLI_MATH_DO_INLINE 1
#ifdef __BLI_MATH_INLINE_H__
#if BLI_MATH_DO_INLINE
# ifdef _MSC_VER
# define MINLINE static __forceinline
# define MALWAYS_INLINE MINLINE

View File

@ -36,7 +36,7 @@ extern "C" {
#include "BLI_math_inline.h"
#ifdef __BLI_MATH_INLINE_H__
#if BLI_MATH_DO_INLINE
#include "intern/math_vector_inline.c"
#endif

View File

@ -174,3 +174,9 @@ if(WIN32)
endif()
blender_add_lib(bf_blenlib "${SRC}" "${INC}" "${INC_SYS}")
if(MSVC)
# Quiet warning about inline math library files that do not export symbols.
# (normally you'd exclude from project, but we still want to see the files in MSVC)
set_target_properties(bf_blenlib PROPERTIES STATIC_LIBRARY_FLAGS /ignore:4221)
endif()

View File

@ -27,6 +27,8 @@
* \ingroup bli
*/
#ifndef __MATH_BASE_INLINE_C__
#define __MATH_BASE_INLINE_C__
#include <float.h>
#include <stdio.h>
@ -35,9 +37,6 @@
#include "BLI_math.h"
#ifndef __MATH_BASE_INLINE_C__
#define __MATH_BASE_INLINE_C__
/* A few small defines. Keep'em local! */
#define SMALL_NUMBER 1.e-8f

View File

@ -27,11 +27,12 @@
* \ingroup bli
*/
#ifndef __MATH_GEOM_INLINE_C__
#define __MATH_GEOM_INLINE_C__
#include "BLI_math.h"
#ifndef __MATH_GEOM_INLINE_C__
#define __MATH_GEOM_INLINE_C__
#include <string.h>
/****************************** Spherical Harmonics **************************/

View File

@ -27,12 +27,11 @@
* \ingroup bli
*/
#include "BLI_math.h"
#ifndef __MATH_VECTOR_INLINE_C__
#define __MATH_VECTOR_INLINE_C__
#include "BLI_math.h"
/********************************** Init *************************************/
MINLINE void zero_v2(float r[2])

View File

@ -56,7 +56,7 @@ char *BLI_strdup(const char *str)
return BLI_strdupn(str, strlen(str));
}
char *BLI_strdupcat(const char *str1, const char *str2)
char *BLI_strdupcat(const char *__restrict str1, const char *__restrict str2)
{
size_t len;
char *n;
@ -69,7 +69,7 @@ char *BLI_strdupcat(const char *str1, const char *str2)
return n;
}
char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy)
char *BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy)
{
size_t srclen = strlen(src);
size_t cpylen = (srclen > (maxncpy - 1)) ? (maxncpy - 1) : srclen;
@ -81,7 +81,7 @@ char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy)
return dst;
}
size_t BLI_vsnprintf(char *buffer, size_t count, const char *format, va_list arg)
size_t BLI_vsnprintf(char *__restrict buffer, size_t count, const char *__restrict format, va_list arg)
{
size_t n;
@ -97,7 +97,7 @@ size_t BLI_vsnprintf(char *buffer, size_t count, const char *format, va_list arg
return n;
}
size_t BLI_snprintf(char *buffer, size_t count, const char *format, ...)
size_t BLI_snprintf(char *__restrict buffer, size_t count, const char *__restrict format, ...)
{
size_t n;
va_list arg;
@ -109,7 +109,7 @@ size_t BLI_snprintf(char *buffer, size_t count, const char *format, ...)
return n;
}
char *BLI_sprintfN(const char *format, ...)
char *BLI_sprintfN(const char *__restrict format, ...)
{
DynStr *ds;
va_list arg;
@ -133,7 +133,7 @@ char *BLI_sprintfN(const char *format, ...)
* TODO: support more fancy string escaping. current code is primitive
* this basically is an ascii version of PyUnicode_EncodeUnicodeEscape()
* which is a useful reference. */
size_t BLI_strescape(char *dst, const char *src, const size_t maxncpy)
size_t BLI_strescape(char *__restrict dst, const char *__restrict src, const size_t maxncpy)
{
size_t len = 0;
@ -186,7 +186,7 @@ escape_finish:
*
* TODO, return the offset and a length so as to avoid doing an allocation.
*/
char *BLI_str_quoted_substrN(const char *str, const char *prefix)
char *BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict prefix)
{
size_t prefixLen = strlen(prefix);
char *startMatch, *endMatch;
@ -207,7 +207,7 @@ char *BLI_str_quoted_substrN(const char *str, const char *prefix)
/* A rather wasteful string-replacement utility, though this shall do for now...
* Feel free to replace this with an even safe + nicer alternative */
char *BLI_replacestr(char *str, const char *oldText, const char *newText)
char *BLI_replacestr(char *__restrict str, const char *__restrict oldText, const char *__restrict newText)
{
DynStr *ds = NULL;
size_t lenOld = strlen(oldText);

View File

@ -184,7 +184,7 @@ static const size_t utf8_skip_data[256] = {
*dst = '\0'; \
} (void)0
char *BLI_strncpy_utf8(char *dst, const char *src, size_t maxncpy)
char *BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy)
{
char *dst_r = dst;
@ -196,7 +196,7 @@ char *BLI_strncpy_utf8(char *dst, const char *src, size_t maxncpy)
return dst_r;
}
char *BLI_strncat_utf8(char *dst, const char *src, size_t maxncpy)
char *BLI_strncat_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy)
{
while (*dst && maxncpy > 0) {
dst++;
@ -213,7 +213,7 @@ char *BLI_strncat_utf8(char *dst, const char *src, size_t maxncpy)
/* --------------------------------------------------------------------------*/
/* wchar_t / utf8 functions */
size_t BLI_strncpy_wchar_as_utf8(char *dst, const wchar_t *src, const size_t maxncpy)
size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst, const wchar_t *__restrict src, const size_t maxncpy)
{
size_t len = 0;
@ -289,7 +289,7 @@ size_t BLI_strnlen_utf8(const char *start, const size_t maxlen)
return len;
}
size_t BLI_strncpy_wchar_from_utf8(wchar_t *dst_w, const char *src_c, const size_t maxncpy)
size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst_w, const char *__restrict src_c, const size_t maxncpy)
{
int len = 0;
@ -419,7 +419,7 @@ unsigned int BLI_str_utf8_as_unicode(const char *p)
}
/* variant that increments the length */
unsigned int BLI_str_utf8_as_unicode_and_size(const char *p, size_t *index)
unsigned int BLI_str_utf8_as_unicode_and_size(const char *__restrict p, size_t *__restrict index)
{
int i, mask = 0, len;
unsigned int result;
@ -435,7 +435,7 @@ unsigned int BLI_str_utf8_as_unicode_and_size(const char *p, size_t *index)
/* another variant that steps over the index,
* note, currently this also falls back to latin1 for text drawing. */
unsigned int BLI_str_utf8_as_unicode_step(const char *p, size_t *index)
unsigned int BLI_str_utf8_as_unicode_step(const char *__restrict p, size_t *__restrict index)
{
int i, mask = 0, len;
unsigned int result;

View File

@ -123,7 +123,6 @@ set(SRC
composite/nodes/node_composite_pixelate.c
composite/node_composite_tree.c
composite/node_composite_util.c
shader/nodes/node_shader_camera.c
shader/nodes/node_shader_common.c
@ -223,7 +222,6 @@ set(SRC
intern/node_common.c
intern/node_socket.c
composite/node_composite_util.h
shader/node_shader_util.h
texture/node_texture_util.h
@ -236,6 +234,13 @@ set(SRC
intern/node_common.h
)
if(WITH_COMPOSITOR_LEGACY)
list(APPEND SRC
composite/node_composite_util.h
composite/node_composite_util.c
)
endif()
if(WITH_PYTHON)
list(APPEND INC
../python