Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-07-08 10:00:27 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-07-08 10:00:27 +0400
commitb91bc4f037b5c3ce69fef2d6187690ce05ffea62 (patch)
tree1743b926b26e6b06007744a002b4ce3014ad526d /source
parent8ce864784cc6aa5b0a5d27a5f3ef3da1240fab62 (diff)
use gcc attrubutes to warn on unused return values and arguments which shouldnt be NULL.
also remove IDP_AppendArray's return value which wasnt the new item in the array (which is odd/misleading), but wasnt used anywhere either.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_idprop.h152
-rw-r--r--source/blender/blenkernel/BKE_lamp.h6
-rw-r--r--source/blender/blenkernel/BKE_library.h21
-rw-r--r--source/blender/blenkernel/intern/idprop.c9
-rw-r--r--source/blender/blenkernel/intern/lamp.c2
-rw-r--r--source/blender/blenlib/BLI_string.h113
-rw-r--r--source/blender/compositor/intern/COM_CompositorContext.cpp2
-rw-r--r--source/blender/makesrna/intern/rna_mesh_api.c2
-rw-r--r--source/blender/modifiers/intern/MOD_multires.c2
-rw-r--r--source/blender/python/intern/bpy_library.c12
10 files changed, 262 insertions, 59 deletions
diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h
index 2436ada9eaf..88eb4dc6f97 100644
--- a/source/blender/blenkernel/BKE_idprop.h
+++ b/source/blender/blenkernel/BKE_idprop.h
@@ -60,15 +60,30 @@ typedef union IDPropertyTemplate {
/* note: as a start to move away from the stupid IDP_New function, this type
* has it's own allocation function.*/
-IDProperty *IDP_NewIDPArray(const char *name);
-IDProperty *IDP_CopyIDPArray(IDProperty *array);
+IDProperty *IDP_NewIDPArray(const char *name)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
+IDProperty *IDP_CopyIDPArray(IDProperty *array)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
void IDP_FreeIDPArray(IDProperty *prop);
/* shallow copies item */
void IDP_SetIndexArray(struct IDProperty *prop, int index, struct IDProperty *item);
-struct IDProperty *IDP_GetIndexArray(struct IDProperty *prop, int index);
-struct IDProperty *IDP_AppendArray(struct IDProperty *prop, struct IDProperty *item);
+struct IDProperty *IDP_GetIndexArray(struct IDProperty *prop, int index)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
+void IDP_AppendArray(struct IDProperty *prop, struct IDProperty *item);
void IDP_ResizeIDPArray(struct IDProperty *prop, int len);
/* ----------- Numeric Array Type ----------- */
@@ -77,11 +92,33 @@ void IDP_ResizeArray(struct IDProperty *prop, int newlen);
void IDP_FreeArray(struct IDProperty *prop);
/* ---------- String Type ------------ */
-IDProperty *IDP_NewString(const char *st, const char *name, int maxlen); /* maxlen excludes '\0' */
-void IDP_AssignString(struct IDProperty *prop, const char *st, int maxlen); /* maxlen excludes '\0' */
-void IDP_ConcatStringC(struct IDProperty *prop, const char *st);
-void IDP_ConcatString(struct IDProperty *str1, struct IDProperty *append);
-void IDP_FreeString(struct IDProperty *prop);
+IDProperty *IDP_NewString(const char *st, const char *name, int maxlen) /* maxlen excludes '\0' */
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
+
+void IDP_AssignString(struct IDProperty *prop, const char *st, int maxlen) /* maxlen excludes '\0' */
+#ifdef __GNUC__
+__attribute__((nonnull))
+#endif
+;
+void IDP_ConcatStringC(struct IDProperty *prop, const char *st)
+#ifdef __GNUC__
+__attribute__((nonnull))
+#endif
+;
+void IDP_ConcatString(struct IDProperty *str1, struct IDProperty *append)
+#ifdef __GNUC__
+__attribute__((nonnull))
+#endif
+;
+void IDP_FreeString(struct IDProperty *prop)
+#ifdef __GNUC__
+__attribute__((nonnull))
+#endif
+;
/*-------- ID Type -------*/
void IDP_LinkID(struct IDProperty *prop, ID *id);
@@ -90,17 +127,29 @@ void IDP_UnlinkID(struct IDProperty *prop);
/*-------- Group Functions -------*/
/** Sync values from one group to another, only where they match */
-void IDP_SyncGroupValues(struct IDProperty *dest, struct IDProperty *src);
+void IDP_SyncGroupValues(struct IDProperty *dest, struct IDProperty *src)
+#ifdef __GNUC__
+__attribute__((nonnull))
+#endif
+;
/**
* replaces all properties with the same name in a destination group from a source group.
*/
-void IDP_ReplaceGroupInGroup(struct IDProperty *dest, struct IDProperty *src);
+void IDP_ReplaceGroupInGroup(struct IDProperty *dest, struct IDProperty *src)
+#ifdef __GNUC__
+__attribute__((nonnull))
+#endif
+;
/**
* Checks if a property with the same name as prop exists, and if so replaces it.
* Use this to preserve order!*/
-void IDP_ReplaceInGroup(struct IDProperty *group, struct IDProperty *prop);
+void IDP_ReplaceInGroup(struct IDProperty *group, struct IDProperty *prop)
+#ifdef __GNUC__
+__attribute__((nonnull))
+#endif
+;
/**
* This function has a sanity check to make sure ID properties with the same name don't
@@ -117,12 +166,20 @@ void IDP_ReplaceInGroup(struct IDProperty *group, struct IDProperty *prop);
* struct. In the future this will just be IDP_FreeProperty and the code will
* be reorganized to work properly.
*/
-int IDP_AddToGroup(struct IDProperty *group, struct IDProperty *prop);
+int IDP_AddToGroup(struct IDProperty *group, struct IDProperty *prop)
+#ifdef __GNUC__
+__attribute__((nonnull))
+#endif
+;
/** this is the same as IDP_AddToGroup, only you pass an item
* in the group list to be inserted after. */
int IDP_InsertToGroup(struct IDProperty *group, struct IDProperty *previous,
- struct IDProperty *pnew);
+ struct IDProperty *pnew)
+#ifdef __GNUC__
+__attribute__((nonnull))
+#endif
+;
/** \note this does not free the property!!
*
@@ -130,18 +187,36 @@ int IDP_InsertToGroup(struct IDProperty *group, struct IDProperty *previous,
* IDP_FreeProperty(prop); //free all subdata
* MEM_freeN(prop); //free property struct itself
*/
-void IDP_RemFromGroup(struct IDProperty *group, struct IDProperty *prop);
+void IDP_RemFromGroup(struct IDProperty *group, struct IDProperty *prop)
+#ifdef __GNUC__
+__attribute__((nonnull))
+#endif
+;
-IDProperty *IDP_GetPropertyFromGroup(struct IDProperty *prop, const char *name);
+IDProperty *IDP_GetPropertyFromGroup(struct IDProperty *prop, const char *name)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
/** same as above but ensure type match */
-IDProperty *IDP_GetPropertyTypeFromGroup(struct IDProperty *prop, const char *name, const char type);
+IDProperty *IDP_GetPropertyTypeFromGroup(struct IDProperty *prop, const char *name, const char type)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
/**
* Get an iterator to iterate over the members of an id property group.
* Note that this will automatically free the iterator once iteration is complete;
* if you stop the iteration before hitting the end, make sure to call
* IDP_FreeIterBeforeEnd(). */
-void *IDP_GetGroupIterator(struct IDProperty *prop);
+void *IDP_GetGroupIterator(struct IDProperty *prop)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+#endif
+;
/**
* Returns the next item in the iteration. To use, simple for a loop like the following:
@@ -149,21 +224,45 @@ void *IDP_GetGroupIterator(struct IDProperty *prop);
* ...
* }
*/
-IDProperty *IDP_GroupIterNext(void *vself);
+IDProperty *IDP_GroupIterNext(void *vself)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
/**
* Frees the iterator pointed to at vself, only use this if iteration is stopped early;
* when the iterator hits the end of the list it'll automatically free itself.*/
-void IDP_FreeIterBeforeEnd(void *vself);
+void IDP_FreeIterBeforeEnd(void *vself)
+#ifdef __GNUC__
+__attribute__((nonnull))
+#endif
+;
/*-------- Main Functions --------*/
/** Get the Group property that contains the id properties for ID id. Set create_if_needed
* to create the Group property and attach it to id if it doesn't exist; otherwise
* the function will return NULL if there's no Group property attached to the ID.*/
-struct IDProperty *IDP_GetProperties(struct ID *id, int create_if_needed);
-struct IDProperty *IDP_CopyProperty(struct IDProperty *prop);
+struct IDProperty *IDP_GetProperties(struct ID *id, int create_if_needed)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
+struct IDProperty *IDP_CopyProperty(struct IDProperty *prop)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
-int IDP_EqualsProperties(struct IDProperty *prop1, struct IDProperty *prop2);
+int IDP_EqualsProperties(struct IDProperty *prop1, struct IDProperty *prop2)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
/**
* Allocate a new ID.
@@ -190,7 +289,12 @@ int IDP_EqualsProperties(struct IDProperty *prop1, struct IDProperty *prop2);
* IDP_AddToGroup or MEM_freeN the property, doing anything else might result in
* a memory leak.
*/
-struct IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name);
+struct IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
/** \note this will free all child properties of list arrays and groups!
* Also, note that this does NOT unlink anything! Plus it doesn't free
diff --git a/source/blender/blenkernel/BKE_lamp.h b/source/blender/blenkernel/BKE_lamp.h
index f9137e50d74..3acd4d1986e 100644
--- a/source/blender/blenkernel/BKE_lamp.h
+++ b/source/blender/blenkernel/BKE_lamp.h
@@ -38,9 +38,9 @@ extern "C" {
struct Lamp;
-void *BKE_lamp_add(const char *name);
-struct Lamp *BKE_lamp_copy(struct Lamp *la);
-struct Lamp *localize_lamp(struct Lamp *la);
+struct Lamp *BKE_lamp_add(const char *name) WARN_UNUSED;
+struct Lamp *BKE_lamp_copy(struct Lamp *la) WARN_UNUSED;
+struct Lamp *localize_lamp(struct Lamp *la) WARN_UNUSED;
void BKE_lamp_make_local(struct Lamp *la);
void BKE_lamp_free(struct Lamp *la);
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 3248944dae8..91756448297 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -45,8 +45,18 @@ struct bContext;
struct PointerRNA;
struct PropertyRNA;
-void *BKE_libblock_alloc(struct ListBase *lb, short type, const char *name);
-void *BKE_libblock_copy(struct ID *id);
+void *BKE_libblock_alloc(struct ListBase *lb, short type, const char *name)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
+void *BKE_libblock_copy(struct ID *id)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
void BKE_libblock_copy_data(struct ID *id, const struct ID *id_from, const short do_action);
void BKE_id_lib_local_paths(struct Main *bmain, struct Library *lib, struct ID *id);
@@ -82,7 +92,12 @@ void name_uiprefix_id(char *name, struct ID *id);
void test_idbutton(char *name);
void text_idbutton(struct ID *id, char *text);
void BKE_library_make_local(struct Main *bmain, struct Library *lib, int untagged_only);
-struct ID *BKE_libblock_find_name(const short type, const char *name);
+struct ID *BKE_libblock_find_name(const short type, const char *name)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
void clear_id_newpoins(void);
void IDnames_to_pupstring(const char **str, const char *title, const char *extraops,
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index 42c7869a365..cff6ab2f125 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -33,11 +33,13 @@
#include <stddef.h>
#include <string.h>
+#include "BLI_utildefines.h"
+#include "BLI_string.h"
+#include "BLI_listbase.h"
+
#include "BKE_idprop.h"
#include "BKE_library.h"
-#include "BLI_blenlib.h"
-
#include "MEM_guardedalloc.h"
/* IDPropertyTemplate is a union in DNA_ID.h */
@@ -122,11 +124,10 @@ IDProperty *IDP_GetIndexArray(IDProperty *prop, int index)
return GETPROP(prop, index);
}
-IDProperty *IDP_AppendArray(IDProperty *prop, IDProperty *item)
+void IDP_AppendArray(IDProperty *prop, IDProperty *item)
{
IDP_ResizeIDPArray(prop, prop->len + 1);
IDP_SetIndexArray(prop, prop->len - 1, item);
- return item;
}
void IDP_ResizeIDPArray(IDProperty *prop, int newlen)
diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c
index 20e3edc7044..4782d09a7c8 100644
--- a/source/blender/blenkernel/intern/lamp.c
+++ b/source/blender/blenkernel/intern/lamp.c
@@ -51,7 +51,7 @@
#include "BKE_main.h"
#include "BKE_node.h"
-void *BKE_lamp_add(const char *name)
+Lamp *BKE_lamp_add(const char *name)
{
Lamp *la;
diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h
index c8f439c677f..8fde8fcf13f 100644
--- a/source/blender/blenlib/BLI_string.h
+++ b/source/blender/blenlib/BLI_string.h
@@ -43,7 +43,12 @@ extern "C" {
* \param str The string to be duplicated
* \retval Returns the duplicated string
*/
-char *BLI_strdup(const char *str);
+char *BLI_strdup(const char *str)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
/**
* Duplicates the first \a len bytes of cstring \a str
@@ -54,7 +59,12 @@ char *BLI_strdup(const char *str);
* \param len The number of bytes to duplicate
* \retval Returns the duplicated string
*/
-char *BLI_strdupn(const char *str, const size_t len);
+char *BLI_strdupn(const char *str, const size_t len)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
/**
* Appends the two strings, and returns new mallocN'ed string
@@ -62,7 +72,12 @@ char *BLI_strdupn(const char *str, const size_t len);
* \param str2 second string for append
* \retval Returns dst
*/
-char *BLI_strdupcat(const char *str1, const char *str2);
+char *BLI_strdupcat(const char *str1, const char *str2)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
/**
* Like strncpy but ensures dst is always
@@ -74,9 +89,14 @@ char *BLI_strdupcat(const char *str1, const char *str2);
* the size of dst)
* \retval Returns dst
*/
-char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy);
+char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy)
+#ifdef __GNUC__
+__attribute__((nonnull))
+#endif
+;
-/* Makes a copy of the text within the "" that appear after some text 'blahblah'
+/**
+ *Makes a copy of the text within the "" that appear after some text 'blahblah'
* i.e. for string 'pose["apples"]' with prefix 'pose[', it should grab "apples"
*
* - str: is the entire string to chop
@@ -85,7 +105,12 @@ char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy);
* Assume that the strings returned must be freed afterwards, and that the inputs will contain
* data we want...
*/
-char *BLI_getQuotedStr(const char *str, const char *prefix);
+char *BLI_getQuotedStr(const char *str, const char *prefix)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
/**
* Returns a copy of the cstring \a str into a newly mallocN'd
@@ -97,7 +122,12 @@ char *BLI_getQuotedStr(const char *str, const char *prefix);
* \param newText The text in the string to find and replace
* \retval Returns the duplicated string
*/
-char *BLI_replacestr(char *str, const char *oldText, const char *newText);
+char *BLI_replacestr(char *str, const char *oldText, const char *newText)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
/*
* Replacement for snprintf
@@ -105,6 +135,7 @@ char *BLI_replacestr(char *str, const char *oldText, const char *newText);
size_t BLI_snprintf(char *buffer, size_t len, const char *format, ...)
#ifdef __GNUC__
__attribute__ ((format(printf, 3, 4)))
+__attribute__((nonnull))
#endif
;
@@ -115,27 +146,75 @@ __attribute__ ((format(printf, 3, 4)))
char *BLI_sprintfN(const char *format, ...)
#ifdef __GNUC__
__attribute__ ((format(printf, 1, 2)))
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
#endif
;
-size_t BLI_strescape(char *dst, const char *src, const size_t maxlen);
+size_t BLI_strescape(char *dst, const char *src, const size_t maxlen)
+#ifdef __GNUC__
+__attribute__((nonnull))
+#endif
+;
/**
* Compare two strings without regard to case.
*
* \retval True if the strings are equal, false otherwise.
*/
-int BLI_strcaseeq(const char *a, const char *b);
+int BLI_strcaseeq(const char *a, const char *b)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
-char *BLI_strcasestr(const char *s, const char *find);
-int BLI_strcasecmp(const char *s1, const char *s2);
-int BLI_strncasecmp(const char *s1, const char *s2, size_t len);
-int BLI_natstrcmp(const char *s1, const char *s2);
-size_t BLI_strnlen(const char *str, size_t maxlen);
-void BLI_timestr(double _time, char *str); /* time var is global */
+char *BLI_strcasestr(const char *s, const char *find)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
+int BLI_strcasecmp(const char *s1, const char *s2)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
+int BLI_strncasecmp(const char *s1, const char *s2, size_t len)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
+int BLI_natstrcmp(const char *s1, const char *s2)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
+size_t BLI_strnlen(const char *str, size_t maxlen)
+#ifdef __GNUC__
+__attribute__((warn_unused_result))
+__attribute__((nonnull))
+#endif
+;
+void BLI_timestr(double _time, char *str)
+#ifdef __GNUC__
+__attribute__((nonnull))
+#endif
+; /* time var is global */
-void BLI_ascii_strtolower(char *str, int len);
-void BLI_ascii_strtoupper(char *str, int len);
+void BLI_ascii_strtolower(char *str, int len)
+#ifdef __GNUC__
+__attribute__((nonnull))
+#endif
+;
+void BLI_ascii_strtoupper(char *str, int len)
+#ifdef __GNUC__
+__attribute__((nonnull))
+#endif
+;
#ifdef __cplusplus
}
diff --git a/source/blender/compositor/intern/COM_CompositorContext.cpp b/source/blender/compositor/intern/COM_CompositorContext.cpp
index fbdb4cd6b28..23a15d54b80 100644
--- a/source/blender/compositor/intern/COM_CompositorContext.cpp
+++ b/source/blender/compositor/intern/COM_CompositorContext.cpp
@@ -26,7 +26,7 @@
CompositorContext::CompositorContext()
{
- this->m_rd = NULL;
+ this->m_rd = 0;
this->m_quality = COM_QUALITY_HIGH;
this->m_hasActiveOpenCLDevices = false;
this->m_activegNode = NULL;
diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c
index ec03d452b57..fe18e6254d0 100644
--- a/source/blender/makesrna/intern/rna_mesh_api.c
+++ b/source/blender/makesrna/intern/rna_mesh_api.c
@@ -36,6 +36,8 @@
#include "BLO_sys_types.h"
+#include "BLI_utildefines.h"
+
#include "BKE_mesh.h"
#include "ED_mesh.h"
diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c
index 472836e3716..afc85a8144e 100644
--- a/source/blender/modifiers/intern/MOD_multires.c
+++ b/source/blender/modifiers/intern/MOD_multires.c
@@ -38,6 +38,8 @@
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
+#include "BLI_utildefines.h"
+
#include "BKE_cdderivedmesh.h"
#include "BKE_mesh.h"
#include "BKE_multires.h"
diff --git a/source/blender/python/intern/bpy_library.c b/source/blender/python/intern/bpy_library.c
index d34bdfe9448..40ec8136eb7 100644
--- a/source/blender/python/intern/bpy_library.c
+++ b/source/blender/python/intern/bpy_library.c
@@ -39,6 +39,12 @@
#include "BLO_readfile.h"
+#include "BLI_utildefines.h"
+#include "BLI_string.h"
+#include "BLI_linklist.h"
+#include "BLI_path_util.h"
+#include "BLI_listbase.h"
+
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_library.h"
@@ -46,12 +52,6 @@
#include "BKE_report.h"
#include "BKE_context.h"
-#include "BLI_utildefines.h"
-#include "BLI_string.h"
-#include "BLI_linklist.h"
-#include "BLI_path_util.h"
-#include "BLI_listbase.h"
-
#include "DNA_space_types.h" /* FILE_LINK, FILE_RELPATH */
#include "bpy_util.h"