now with the list in copy...

--- Rolf Meeser <[email protected]> schrieb am Mo, 14.9.2009:

> Von: Rolf Meeser <[email protected]>
> Betreff: AW: [Openocd-development] compile error in R:2703
> An: "Paul Thomas" <[email protected]>
> Datum: Montag, 14. September 2009, 9:07
> Hi Paul,
> 
> --- Paul Thomas <[email protected]>
> schrieb am Mo, 14.9.2009:
> 
> > cfi.c: In function ‘cfi_spansion_write_block’:
> > cfi.c:1451: error: ‘target_code_size’ may be used
> > uninitialized in this function
> > make[3]: *** [cfi.lo] Error 1
> > make[3]: Leaving directory
> > `/home/bulk/openocd_trunk/src/flash'
> > make[2]: *** [all-recursive] Error 1
> > make[2]: Leaving directory
> `/home/bulk/openocd_trunk/src'
> > make[1]: *** [all-recursive] Error 1
> > make[1]: Leaving directory `/home/bulk/openocd_trunk'
> > make: *** [all] Error 2
> > 
> > I'm on a Fedora 11 x86_64 system. This isn't a huge
> deal
> > for me right
> > now, but I thought you guys might like to know.
> > 
> > thanks,
> > Paul
> 
> Caused by a patch that I sent recently.
> 
> It's a real bug! Doesn't show up here with both gcc 4.3.4
> and 4.4.1 though.
> Doesn't fail to compile, not even a warning...
> 
> I duplicated a solution for this from
> cfi_intel_write_block(). That code now takes care of
> initializing target_code_size.
> 
> As I can't reproduce it here, could you please check if the
> attached patch compiles fine for you now?
> 
> Regards,
> Rolf
> 
> 
> 
>       


      
Index: src/flash/cfi.c
===================================================================
--- src/flash/cfi.c	(revision 2685)
+++ src/flash/cfi.c	(working copy)
@@ -1125,12 +1125,12 @@
 	armv4_5_info.core_state = ARMV4_5_STATE_ARM;
 
 	/* If we are setting up the write_algorith, we need target_code_src */
-	/* if not we only need target_code_size.														*/
-	/* 																																	*/
-	/* However, we don't want to create multiple code paths, so we			*/
-	/* do the unecessary evaluation of target_code_src, which the 			*/
-	/* compiler will probably nicely optimize away if not needed				*/
+	/* if not we only need target_code_size. */
 
+	/* However, we don't want to create multiple code paths, so we */
+	/* do the unecessary evaluation of target_code_src, which the */
+	/* compiler will probably nicely optimize away if not needed */
+
 	/* prepare algorithm code for target endian */
 	switch (bank->bus_width)
 	{
@@ -1447,44 +1447,46 @@
 	armv4_5_info.core_mode = ARMV4_5_MODE_SVC;
 	armv4_5_info.core_state = ARMV4_5_STATE_ARM;
 
+	int target_code_size;
+	const uint32_t *target_code_src;
+
+	switch (bank->bus_width)
+	{
+	case 1 :
+		target_code_src = word_8_code;
+		target_code_size = sizeof(word_8_code);
+		break;
+	case 2 :
+		/* Check for DQ5 support */
+		if( cfi_info->status_poll_mask & (1 << 5) )
+		{
+			target_code_src = word_16_code;
+			target_code_size = sizeof(word_16_code);
+		}
+		else
+		{
+			/* No DQ5 support. Use DQ7 DATA# polling only. */
+			target_code_src = word_16_code_dq7only;
+			target_code_size = sizeof(word_16_code_dq7only);
+		}
+		break;
+	case 4 :
+		target_code_src = word_32_code;
+		target_code_size = sizeof(word_32_code);
+		break;
+	default:
+		LOG_ERROR("Unsupported bank buswidth %d, can't do block memory writes", bank->bus_width);
+		return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
+	}
+
 	/* flash write code */
-	int target_code_size;
 	if (!cfi_info->write_algorithm)
 	{
 		uint8_t *target_code;
-		const uint32_t *src;
 
 		/* convert bus-width dependent algorithm code to correct endiannes */
-		switch (bank->bus_width)
-		{
-		case 1:
-			src = word_8_code;
-			target_code_size = sizeof(word_8_code);
-			break;
-		case 2:
-			/* Check for DQ5 support */
-			if( cfi_info->status_poll_mask & (1 << 5) )
-			{
-				src = word_16_code;
-				target_code_size = sizeof(word_16_code);
-			}
-			else
-			{
-				/* No DQ5 support. Use DQ7 DATA# polling only. */
-				src = word_16_code_dq7only;
-				target_code_size = sizeof(word_16_code_dq7only);
-			}
-			break;
-		case 4:
-			src = word_32_code;
-			target_code_size = sizeof(word_32_code);
-			break;
-		default:
-			LOG_ERROR("Unsupported bank buswidth %d, can't do block memory writes", bank->bus_width);
-			return ERROR_FLASH_OPERATION_FAILED;
-		}
 		target_code = malloc(target_code_size);
-		cfi_fix_code_endian(target, target_code, src, target_code_size / 4);
+		cfi_fix_code_endian(target, target_code, target_code_src, target_code_size / 4);
 
 		/* allocate working area */
 		retval = target_alloc_working_area(target, target_code_size,
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to