target: clean up target memory allocation error messages
authorØyvind Harboe <oyvind.harboe@zylin.com>
Mon, 3 May 2010 13:49:23 +0000 (15:49 +0200)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Tue, 4 May 2010 07:11:20 +0000 (09:11 +0200)
target memory allocation can be implemented not to show
bogus error messages.

E.g. when trying a big allocation first and then a
smaller one if that fails.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
src/target/target.c
src/target/target.h

index 73594fb0b9e478b0073cbb53bac78b770af47307..a3a1b0adb763a32c27ad3a4039a73d828fd5cd9a 100644 (file)
@@ -1111,7 +1111,7 @@ int target_call_timer_callbacks_now(void)
        return target_call_timer_callbacks_check_time(0);
 }
 
-int target_alloc_working_area(struct target *target, uint32_t size, struct working_area **area)
+int target_alloc_working_area_try(struct target *target, uint32_t size, struct working_area **area)
 {
        struct working_area *c = target->working_areas;
        struct working_area *new_wa = NULL;
@@ -1189,8 +1189,6 @@ int target_alloc_working_area(struct target *target, uint32_t size, struct worki
 
                if (free_size < size)
                {
-                       LOG_WARNING("not enough working area available(requested %u, free %u)",
-                                   (unsigned)(size), (unsigned)(free_size));
                        return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
                }
 
@@ -1231,6 +1229,19 @@ int target_alloc_working_area(struct target *target, uint32_t size, struct worki
        return ERROR_OK;
 }
 
+int target_alloc_working_area(struct target *target, uint32_t size, struct working_area **area)
+{
+       int retval;
+
+       retval = target_alloc_working_area_try(target, size, area);
+       if (retval == ERROR_TARGET_RESOURCE_NOT_AVAILABLE)
+       {
+               LOG_WARNING("not enough working area available(requested %u)", (unsigned)(size));
+       }
+       return retval;
+
+}
+
 static int target_free_working_area_restore(struct target *target, struct working_area *area, int restore)
 {
        if (area->free)
index 0292945d2c6e34a802f1889b7b64294fa54d97f8..4a48e5aad6c08c892d16e57d9d3d3fde1b74e83c 100644 (file)
@@ -452,6 +452,14 @@ const char *target_state_name( struct target *target );
  */
 int target_alloc_working_area(struct target *target,
                uint32_t size, struct working_area **area);
+/* Same as target_alloc_working_area, except that no error is logged
+ * when ERROR_TARGET_RESOURCE_NOT_AVAILABLE is returned.
+ *
+ * This allows the calling code to *try* to allocate target memory
+ * and have a fallback to another behavior(slower?).
+ */
+int target_alloc_working_area_try(struct target *target,
+               uint32_t size, struct working_area **area);
 int target_free_working_area(struct target *target, struct working_area *area);
 void target_free_all_working_areas(struct target *target);
 

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)