[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43320] trunk/blender/source/blender: replace fixed sizes with sizeof when passing string length since size wasn 't always correct.

Campbell Barton ideasman42 at gmail.com
Thu Jan 12 14:16:38 CET 2012


Revision: 43320
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43320
Author:   campbellbarton
Date:     2012-01-12 13:16:30 +0000 (Thu, 12 Jan 2012)
Log Message:
-----------
replace fixed sizes with sizeof when passing string length since size wasn't always correct.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/writeframeserver.c
    trunk/blender/source/blender/blenlib/intern/fileops.c
    trunk/blender/source/blender/editors/interface/interface.c
    trunk/blender/source/blender/editors/interface/interface_handlers.c
    trunk/blender/source/blender/editors/interface/interface_regions.c
    trunk/blender/source/blender/editors/interface/interface_templates.c
    trunk/blender/source/blender/editors/physics/physics_fluid.c
    trunk/blender/source/blender/editors/render/render_preview.c
    trunk/blender/source/blender/editors/space_outliner/outliner_draw.c
    trunk/blender/source/blender/editors/space_view3d/view3d_buttons.c
    trunk/blender/source/blender/editors/space_view3d/view3d_toolbar.c
    trunk/blender/source/blender/imbuf/intern/indexer.c
    trunk/blender/source/blender/windowmanager/intern/wm_operators.c

Modified: trunk/blender/source/blender/blenkernel/intern/writeframeserver.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/writeframeserver.c	2012-01-12 12:35:52 UTC (rev 43319)
+++ trunk/blender/source/blender/blenkernel/intern/writeframeserver.c	2012-01-12 13:16:30 UTC (rev 43320)
@@ -310,7 +310,7 @@
 		}
 	}
 
-	len = recv(connsock, buf, 4095, 0);
+	len = recv(connsock, buf, sizeof(buf) - 1, 0);
 
 	if (len < 0) {
 		return -1;

Modified: trunk/blender/source/blender/blenlib/intern/fileops.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/fileops.c	2012-01-12 12:35:52 UTC (rev 43319)
+++ trunk/blender/source/blender/blenlib/intern/fileops.c	2012-01-12 13:16:30 UTC (rev 43320)
@@ -82,7 +82,7 @@
 		return -2;
 
 	while(1) {
-		readsize = read(file, buffer, 10240);
+		readsize = read(file, buffer, sizeof(buffer));
 
 		if(readsize < 0) {
 			rval= -2; /* error happened in reading */

Modified: trunk/blender/source/blender/editors/interface/interface.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface.c	2012-01-12 12:35:52 UTC (rev 43319)
+++ trunk/blender/source/blender/editors/interface/interface.c	2012-01-12 13:16:30 UTC (rev 43320)
@@ -831,7 +831,9 @@
 		if(but->optype) {
 			IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
 
-			if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, buf, sizeof(buf))) {
+			if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE,
+			                                buf, sizeof(buf)))
+			{
 				UI_MENU_KEY_STR_CAT
 			}
 		}
@@ -846,7 +848,9 @@
 
 			IDP_AssignString(prop_menu_name, mt->idname, sizeof(mt->idname));
 
-			if(WM_key_event_operator_string(C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, FALSE, buf, sizeof(buf))) {
+			if(WM_key_event_operator_string(C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, FALSE,
+			                                buf, sizeof(buf)))
+			{
 				UI_MENU_KEY_STR_CAT
 			}
 		}

Modified: trunk/blender/source/blender/editors/interface/interface_handlers.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_handlers.c	2012-01-12 12:35:52 UTC (rev 43319)
+++ trunk/blender/source/blender/editors/interface/interface_handlers.c	2012-01-12 13:16:30 UTC (rev 43320)
@@ -4388,7 +4388,9 @@
 		IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
 		
 		/* complex code to change name of button */
-		if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, buf, sizeof(buf))) {
+		if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE,
+		                                buf, sizeof(buf)))
+		{
 			char *butstr_orig;
 
 			// XXX but->str changed... should not, remove the hotkey from it

Modified: trunk/blender/source/blender/editors/interface/interface_regions.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_regions.c	2012-01-12 12:35:52 UTC (rev 43319)
+++ trunk/blender/source/blender/editors/interface/interface_regions.c	2012-01-12 13:16:30 UTC (rev 43320)
@@ -409,7 +409,9 @@
 		/* operator keymap (not menus, they already have it) */
 		prop= (but->opptr)? but->opptr->data: NULL;
 
-		if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, buf, sizeof(buf))) {
+		if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE,
+		                                buf, sizeof(buf)))
+		{
 			BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Shortcut: %s"), buf);
 			data->color[data->totline]= 0x888888;
 			data->totline++;

Modified: trunk/blender/source/blender/editors/interface/interface_templates.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_templates.c	2012-01-12 12:35:52 UTC (rev 43319)
+++ trunk/blender/source/blender/editors/interface/interface_templates.c	2012-01-12 13:16:30 UTC (rev 43320)
@@ -181,7 +181,7 @@
 		/* fake button, it holds space for search items */
 		uiDefBut(block, LABEL, 0, "", 10, 15, w, h, NULL, 0, 0, 0, 0, NULL);
 		
-		but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, 256, 10, 0, w, 19, template.prv_rows, template.prv_cols, "");
+		but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, w, 19, template.prv_rows, template.prv_cols, "");
 		uiButSetSearchFunc(but, id_search_cb, &template, id_search_call_cb, idptr.data);
 	}
 	/* list view */
@@ -189,7 +189,7 @@
 		/* fake button, it holds space for search items */
 		uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL);
 		
-		but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, 256, 10, 0, 150, 19, 0, 0, "");
+		but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, 150, 19, 0, 0, "");
 		uiButSetSearchFunc(but, id_search_cb, &template, id_search_call_cb, idptr.data);
 	}
 		

Modified: trunk/blender/source/blender/editors/physics/physics_fluid.c
===================================================================
--- trunk/blender/source/blender/editors/physics/physics_fluid.c	2012-01-12 12:35:52 UTC (rev 43319)
+++ trunk/blender/source/blender/editors/physics/physics_fluid.c	2012-01-12 13:16:30 UTC (rev 43320)
@@ -884,7 +884,7 @@
 	if(getenv(strEnvName)) {
 		int dlevel = atoi(getenv(strEnvName));
 		elbeemSetDebugLevel(dlevel);
-		BLI_snprintf(debugStrBuffer,256,"fluidsimBake::msg: Debug messages activated due to envvar '%s'\n",strEnvName); 
+		BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer),"fluidsimBake::msg: Debug messages activated due to envvar '%s'\n",strEnvName);
 		elbeemDebugOut(debugStrBuffer);
 	}
 	
@@ -921,7 +921,7 @@
 	
 	/* rough check of settings... */
 	if(domainSettings->previewresxyz > domainSettings->resolutionxyz) {
-		BLI_snprintf(debugStrBuffer,256,"fluidsimBake::warning - Preview (%d) >= Resolution (%d)... setting equal.\n", domainSettings->previewresxyz ,  domainSettings->resolutionxyz); 
+		BLI_snprintf(debugStrBuffer,sizeof(debugStrBuffer),"fluidsimBake::warning - Preview (%d) >= Resolution (%d)... setting equal.\n", domainSettings->previewresxyz ,  domainSettings->resolutionxyz);
 		elbeemDebugOut(debugStrBuffer);
 		domainSettings->previewresxyz = domainSettings->resolutionxyz;
 	}
@@ -941,7 +941,7 @@
 	} else {
 		gridlevels = domainSettings->maxRefine;
 	}
-	BLI_snprintf(debugStrBuffer,256,"fluidsimBake::msg: Baking %s, refine: %d\n", fsDomain->id.name , gridlevels ); 
+	BLI_snprintf(debugStrBuffer,sizeof(debugStrBuffer),"fluidsimBake::msg: Baking %s, refine: %d\n", fsDomain->id.name , gridlevels );
 	elbeemDebugOut(debugStrBuffer);
 	
 	
@@ -993,7 +993,7 @@
 	/* ******** init domain object's matrix ******** */
 	copy_m4_m4(domainMat, fsDomain->obmat);
 	if(!invert_m4_m4(invDomMat, domainMat)) {
-		BLI_snprintf(debugStrBuffer,256,"fluidsimBake::error - Invalid obj matrix?\n"); 
+		BLI_snprintf(debugStrBuffer,sizeof(debugStrBuffer),"fluidsimBake::error - Invalid obj matrix?\n");
 		elbeemDebugOut(debugStrBuffer);
 		BKE_report(reports, RPT_ERROR, "Invalid object matrix"); 
 

Modified: trunk/blender/source/blender/editors/render/render_preview.c
===================================================================
--- trunk/blender/source/blender/editors/render/render_preview.c	2012-01-12 12:35:52 UTC (rev 43319)
+++ trunk/blender/source/blender/editors/render/render_preview.c	2012-01-12 13:16:30 UTC (rev 43320)
@@ -104,7 +104,7 @@
 {
 	static const int flags = IB_rect|IB_multilayer|IB_metadata;
 
-	char path[240];
+	char path[FILE_MAX];
 	char *folder;
 
 	if (!(brush->icon_imbuf)) {

Modified: trunk/blender/source/blender/editors/space_outliner/outliner_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_outliner/outliner_draw.c	2012-01-12 12:35:52 UTC (rev 43319)
+++ trunk/blender/source/blender/editors/space_outliner/outliner_draw.c	2012-01-12 13:16:30 UTC (rev 43320)
@@ -628,7 +628,7 @@
 	/* fake button, it holds space for search items */
 	uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL);
 	
-	but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, 256, 10, 0, 150, UI_UNIT_Y, 0, 0, "");
+	but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, 150, UI_UNIT_Y, 0, 0, "");
 	uiButSetSearchFunc(but, operator_search_cb, arg_kmi, operator_call_cb, ot);
 	
 	uiBoundsBlock(block, 6);

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_buttons.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_buttons.c	2012-01-12 12:35:52 UTC (rev 43319)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_buttons.c	2012-01-12 13:16:30 UTC (rev 43320)
@@ -188,7 +188,7 @@
 				dg = BLI_findlink (&ob->defbase, dvert->dw[i].def_nr);
 				if(dg) {
 					max+= BLI_snprintf(str, sizeof(str), "%s %%x%d|", dg->name, dvert->dw[i].def_nr); 
-					if(max<320) strcat(defstr, str);
+					if (max < sizeof(str)) strcat(defstr, str);
 				}
 
 				if(tfp->curdef==dvert->dw[i].def_nr) {

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_toolbar.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_toolbar.c	2012-01-12 12:35:52 UTC (rev 43319)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_toolbar.c	2012-01-12 13:16:30 UTC (rev 43320)
@@ -177,7 +177,7 @@
 	/* fake button, it holds space for search items */
 	uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL);
 	
-	but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, OP_MAX_TYPENAME, 10, 0, 150, 19, 0, 0, "");
+	but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, 150, 19, 0, 0, "");
 	uiButSetSearchFunc(but, operator_search_cb, arg_listbase, operator_call_cb, NULL);
 	
 	uiBoundsBlock(block, 6);

Modified: trunk/blender/source/blender/imbuf/intern/indexer.c
===================================================================

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-blender-cvs mailing list