[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33466] trunk/blender/source/blender: Give functions that use printf style formatting GCC format attributes so if incorrect formatting is used the compiler will warn of this .

Campbell Barton ideasman42 at gmail.com
Sat Dec 4 12:44:56 CET 2010


Revision: 33466
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33466
Author:   campbellbarton
Date:     2010-12-04 12:44:56 +0100 (Sat, 04 Dec 2010)

Log Message:
-----------
Give functions that use printf style formatting GCC format attributes so if incorrect formatting is used the compiler will warn of this.
found & fixed 2x incorrect formatting args.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_modifier.h
    trunk/blender/source/blender/blenkernel/BKE_report.h
    trunk/blender/source/blender/blenlib/BLI_dynstr.h
    trunk/blender/source/blender/blenlib/BLI_string.h
    trunk/blender/source/blender/makesrna/RNA_access.h
    trunk/blender/source/blender/makesrna/intern/rna_ID.c
    trunk/blender/source/blender/makesrna/intern/rna_access.c
    trunk/blender/source/blender/makesrna/intern/rna_animation.c
    trunk/blender/source/blender/makesrna/intern/rna_mesh.c
    trunk/blender/source/blender/makesrna/intern/rna_render.c
    trunk/blender/source/blender/makesrna/intern/rna_ui.c
    trunk/blender/source/blender/makesrna/intern/rna_wm.c
    trunk/blender/source/blender/windowmanager/intern/wm_files.c

Modified: trunk/blender/source/blender/blenkernel/BKE_modifier.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_modifier.h	2010-12-04 11:34:26 UTC (rev 33465)
+++ trunk/blender/source/blender/blenkernel/BKE_modifier.h	2010-12-04 11:44:56 UTC (rev 33466)
@@ -294,7 +294,11 @@
 int           modifier_isCorrectableDeformed(struct ModifierData *md);
 int			  modifier_sameTopology(ModifierData *md);
 int           modifier_isEnabled(struct Scene *scene, struct ModifierData *md, int required_mode);
-void          modifier_setError(struct ModifierData *md, const char *format, ...);
+void          modifier_setError(struct ModifierData *md, const char *format, ...)
+#ifdef __GNUC__
+__attribute__ ((format (printf, 2, 3)));
+#endif
+;
 
 void          modifiers_foreachObjectLink(struct Object *ob,
 										  ObjectWalkFunc walk,

Modified: trunk/blender/source/blender/blenkernel/BKE_report.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_report.h	2010-12-04 11:34:26 UTC (rev 33465)
+++ trunk/blender/source/blender/blenkernel/BKE_report.h	2010-12-04 11:44:56 UTC (rev 33466)
@@ -45,7 +45,11 @@
 void BKE_reports_clear(ReportList *reports);
 
 void BKE_report(ReportList *reports, ReportType type, const char *message);
-void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...);
+void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...)
+#ifdef __GNUC__
+__attribute__ ((format (printf, 3, 4)));
+#endif
+;
 
 void BKE_reports_prepend(ReportList *reports, const char *prepend);
 void BKE_reports_prependf(ReportList *reports, const char *prepend, ...);

Modified: trunk/blender/source/blender/blenlib/BLI_dynstr.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_dynstr.h	2010-12-04 11:34:26 UTC (rev 33465)
+++ trunk/blender/source/blender/blenlib/BLI_dynstr.h	2010-12-04 11:44:56 UTC (rev 33466)
@@ -75,7 +75,11 @@
 	 * @param ds The DynStr to append to.
 	 * @param format The printf format string to use.
 	 */
-void	BLI_dynstr_appendf				(DynStr *ds, const char *format, ...);
+void	BLI_dynstr_appendf				(DynStr *ds, const char *format, ...)
+#ifdef __GNUC__
+__attribute__ ((format (printf, 2, 3)));
+#endif
+;
 void	BLI_dynstr_vappendf				(DynStr *ds, const char *format, va_list args);
 
 	/**

Modified: trunk/blender/source/blender/blenlib/BLI_string.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_string.h	2010-12-04 11:34:26 UTC (rev 33465)
+++ trunk/blender/source/blender/blenlib/BLI_string.h	2010-12-04 11:44:56 UTC (rev 33466)
@@ -102,13 +102,21 @@
 	/* 
 	 * Replacement for snprintf
 	 */
-int BLI_snprintf(char *buffer, size_t count, const char *format, ...);
+int BLI_snprintf(char *buffer, size_t count, const char *format, ...)
+#ifdef __GNUC__
+__attribute__ ((format (printf, 3, 4)));
+#endif
+;
 
 	/* 
 	 * Print formatted string into a newly mallocN'd string
 	 * and return it.
 	 */
-char *BLI_sprintfN(const char *format, ...);
+char *BLI_sprintfN(const char *format, ...)
+#ifdef __GNUC__
+__attribute__ ((format (printf, 1, 2)));
+#endif
+;
 
 	/**
 	 * Compare two strings

Modified: trunk/blender/source/blender/makesrna/RNA_access.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_access.h	2010-12-04 11:34:26 UTC (rev 33465)
+++ trunk/blender/source/blender/makesrna/RNA_access.h	2010-12-04 11:44:56 UTC (rev 33466)
@@ -928,8 +928,16 @@
 int RNA_function_call(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms);
 int RNA_function_call_lookup(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, const char *identifier, ParameterList *parms);
 
-int RNA_function_call_direct(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, FunctionRNA *func, const char *format, ...);
-int RNA_function_call_direct_lookup(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, const char *identifier, const char *format, ...);
+int RNA_function_call_direct(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, FunctionRNA *func, const char *format, ...)
+#ifdef __GNUC__
+__attribute__ ((format (printf, 5, 6)));
+#endif
+;
+int RNA_function_call_direct_lookup(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, const char *identifier, const char *format, ...)
+#ifdef __GNUC__
+__attribute__ ((format (printf, 5, 6)));
+#endif
+;
 int RNA_function_call_direct_va(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, FunctionRNA *func, const char *format, va_list args);
 int RNA_function_call_direct_va_lookup(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, const char *identifier, const char *format, va_list args);
 

Modified: trunk/blender/source/blender/makesrna/intern/rna_ID.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_ID.c	2010-12-04 11:34:26 UTC (rev 33465)
+++ trunk/blender/source/blender/makesrna/intern/rna_ID.c	2010-12-04 11:44:56 UTC (rev 33466)
@@ -224,7 +224,7 @@
 	 * owns the string pointer which it could potentually free while blender
 	 * is running. */
 	if(strlen(identifier) >= sizeof(((IDProperty *)NULL)->name)) {
-		BKE_reportf(reports, RPT_ERROR, "registering id property class: '%s' is too long, maximum length is %d.", identifier, sizeof(((IDProperty *)NULL)->name));
+		BKE_reportf(reports, RPT_ERROR, "registering id property class: '%s' is too long, maximum length is %d.", identifier, (int)sizeof(((IDProperty *)NULL)->name));
 		return NULL;
 	}
 

Modified: trunk/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_access.c	2010-12-04 11:34:26 UTC (rev 33465)
+++ trunk/blender/source/blender/makesrna/intern/rna_access.c	2010-12-04 11:44:56 UTC (rev 33466)
@@ -3771,7 +3771,7 @@
 			BLI_dynstr_appendf(dynstr, "'%s'", identifier);
 		}
 		else {
-			BLI_dynstr_appendf(dynstr, "'<UNKNOWN ENUM>'", identifier);
+			BLI_dynstr_append(dynstr, "'<UNKNOWN ENUM>'");
 		}
 		break;
 	}

Modified: trunk/blender/source/blender/makesrna/intern/rna_animation.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_animation.c	2010-12-04 11:34:26 UTC (rev 33465)
+++ trunk/blender/source/blender/makesrna/intern/rna_animation.c	2010-12-04 11:44:56 UTC (rev 33466)
@@ -173,7 +173,7 @@
 		return NULL;
 	
 	if (strlen(identifier) >= sizeof(dummyksi.idname)) {
-		BKE_reportf(reports, RPT_ERROR, "registering keying set info class: '%s' is too long, maximum length is %d.", identifier, sizeof(dummyksi.idname));
+		BKE_reportf(reports, RPT_ERROR, "registering keying set info class: '%s' is too long, maximum length is %d.", identifier, (int)sizeof(dummyksi.idname));
 		return NULL;
 	}
 	

Modified: trunk/blender/source/blender/makesrna/intern/rna_mesh.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_mesh.c	2010-12-04 11:34:26 UTC (rev 33465)
+++ trunk/blender/source/blender/makesrna/intern/rna_mesh.c	2010-12-04 11:44:56 UTC (rev 33466)
@@ -962,17 +962,17 @@
 
 static char *rna_MeshFace_path(PointerRNA *ptr)
 {
-	return BLI_sprintfN("faces[%d]", (MFace*)ptr->data - ((Mesh*)ptr->id.data)->mface);
+	return BLI_sprintfN("faces[%d]", (int)((MFace*)ptr->data - ((Mesh*)ptr->id.data)->mface));
 }
 
 static char *rna_MeshEdge_path(PointerRNA *ptr)
 {
-	return BLI_sprintfN("edges[%d]", (MEdge*)ptr->data - ((Mesh*)ptr->id.data)->medge);
+	return BLI_sprintfN("edges[%d]", (int)((MEdge*)ptr->data - ((Mesh*)ptr->id.data)->medge));
 }
 
 static char *rna_MeshVertex_path(PointerRNA *ptr)
 {
-	return BLI_sprintfN("vertices[%d]", (MVert*)ptr->data - ((Mesh*)ptr->id.data)->mvert);
+	return BLI_sprintfN("vertices[%d]", (int)((MVert*)ptr->data - ((Mesh*)ptr->id.data)->mvert));
 }
 
 static char *rna_MeshTextureFaceLayer_path(PointerRNA *ptr)
@@ -1015,7 +1015,7 @@
 
 static char *rna_MeshSticky_path(PointerRNA *ptr)
 {
-	return BLI_sprintfN("sticky[%d]", (MSticky*)ptr->data - ((Mesh*)ptr->id.data)->msticky);
+	return BLI_sprintfN("sticky[%d]", (int)((MSticky*)ptr->data - ((Mesh*)ptr->id.data)->msticky));
 }
 
 static char *rna_MeshIntPropertyLayer_path(PointerRNA *ptr)

Modified: trunk/blender/source/blender/makesrna/intern/rna_render.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_render.c	2010-12-04 11:34:26 UTC (rev 33465)
+++ trunk/blender/source/blender/makesrna/intern/rna_render.c	2010-12-04 11:44:56 UTC (rev 33466)
@@ -124,7 +124,7 @@
 		return NULL;
 
 	if(strlen(identifier) >= sizeof(dummyet.idname)) {
-		BKE_reportf(reports, RPT_ERROR, "registering render engine class: '%s' is too long, maximum length is %d.", identifier, sizeof(dummyet.idname));
+		BKE_reportf(reports, RPT_ERROR, "registering render engine class: '%s' is too long, maximum length is %d.", identifier, (int)sizeof(dummyet.idname));
 		return NULL;
 	}
 

Modified: trunk/blender/source/blender/makesrna/intern/rna_ui.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_ui.c	2010-12-04 11:34:26 UTC (rev 33465)
+++ trunk/blender/source/blender/makesrna/intern/rna_ui.c	2010-12-04 11:44:56 UTC (rev 33466)
@@ -180,7 +180,7 @@
 		return NULL;
 		
 	if(strlen(identifier) >= sizeof(dummypt.idname)) {
-		BKE_reportf(reports, RPT_ERROR, "registering panel class: '%s' is too long, maximum length is %d.", identifier, sizeof(dummypt.idname));
+		BKE_reportf(reports, RPT_ERROR, "registering panel class: '%s' is too long, maximum length is %d.", identifier, (int)sizeof(dummypt.idname));
 		return NULL;
 	}
 	
@@ -283,7 +283,7 @@
 		return NULL;
 
 	if(strlen(identifier) >= sizeof(dummyht.idname)) {
-		BKE_reportf(reports, RPT_ERROR, "registering header class: '%s' is too long, maximum length is %d.", identifier, sizeof(dummyht.idname));
+		BKE_reportf(reports, RPT_ERROR, "registering header class: '%s' is too long, maximum length is %d.", identifier, (int)sizeof(dummyht.idname));

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list