This is an automated email from Gerrit.

Paul Fertser ([email protected]) just uploaded a new patch set to Gerrit, 
which you can find at http://openocd.zylin.com/2102

-- gerrit

commit 892a5df90e3981cd268d59263290b73900abcfec
Author: Paul Fertser <[email protected]>
Date:   Sat Apr 12 17:22:00 2014 +0400

    mips32, dsp563xx: fix segfault on Gdb attach
    
    Since c6216201b249e6a97fcc085e413e3d34e0de6fb7 gdb target description
    generation support is enabled by default and it counts on checking
    "feature" pointer in reg_list. Both mips32 and dsp563xx neither used
    calloc nor explicitly set feature (as it was a newly introduced struct
    field).
    
    This patch changes all targets to use calloc for consistency.
    
    Change-Id: I9eceadef8b04aacb108e24ae23cb51ca3009586f
    Signed-off-by: Paul Fertser <[email protected]>

diff --git a/src/target/avr32_ap7k.c b/src/target/avr32_ap7k.c
index 70af8c3..e1812ec 100644
--- a/src/target/avr32_ap7k.c
+++ b/src/target/avr32_ap7k.c
@@ -178,7 +178,7 @@ static struct reg_cache *avr32_build_reg_cache(struct 
target *target)
        struct avr32_ap7k_common *ap7k = target_to_ap7k(target);
        struct reg_cache **cache_p = 
register_get_last_cache_p(&target->reg_cache);
        struct reg_cache *cache = malloc(sizeof(struct reg_cache));
-       struct reg *reg_list = malloc(sizeof(struct reg) * num_regs);
+       struct reg *reg_list = calloc(num_regs, sizeof(struct reg));
        struct avr32_core_reg *arch_info =
                malloc(sizeof(struct avr32_core_reg) * num_regs);
        int i;
diff --git a/src/target/dsp563xx.c b/src/target/dsp563xx.c
index 07df363..2e7ac96 100644
--- a/src/target/dsp563xx.c
+++ b/src/target/dsp563xx.c
@@ -451,7 +451,7 @@ static void dsp563xx_build_reg_cache(struct target *target)
 
        struct reg_cache **cache_p = 
register_get_last_cache_p(&target->reg_cache);
        struct reg_cache *cache = malloc(sizeof(struct reg_cache));
-       struct reg *reg_list = malloc(sizeof(struct reg) * 
DSP563XX_NUMCOREREGS);
+       struct reg *reg_list = calloc(DSP563XX_NUMCOREREGS, sizeof(struct reg));
        struct dsp563xx_core_reg *arch_info = malloc(
                        sizeof(struct dsp563xx_core_reg) * 
DSP563XX_NUMCOREREGS);
        int i;
diff --git a/src/target/lakemont.c b/src/target/lakemont.c
index 70c785c..f3795c1 100644
--- a/src/target/lakemont.c
+++ b/src/target/lakemont.c
@@ -375,7 +375,7 @@ struct reg_cache *lakemont_build_reg_cache(struct target *t)
        int num_regs = ARRAY_SIZE(regs);
        struct reg_cache **cache_p = register_get_last_cache_p(&t->reg_cache);
        struct reg_cache *cache = malloc(sizeof(struct reg_cache));
-       struct reg *reg_list = malloc(sizeof(struct reg) * num_regs);
+       struct reg *reg_list = calloc(num_regs, sizeof(struct reg));
        struct lakemont_core_reg *arch_info = malloc(sizeof(struct 
lakemont_core_reg) * num_regs);
        struct reg_feature *feature;
        int i;
diff --git a/src/target/mips32.c b/src/target/mips32.c
index 11f39fe..7cf5477 100644
--- a/src/target/mips32.c
+++ b/src/target/mips32.c
@@ -252,7 +252,7 @@ struct reg_cache *mips32_build_reg_cache(struct target 
*target)
        int num_regs = MIPS32NUMCOREREGS;
        struct reg_cache **cache_p = 
register_get_last_cache_p(&target->reg_cache);
        struct reg_cache *cache = malloc(sizeof(struct reg_cache));
-       struct reg *reg_list = malloc(sizeof(struct reg) * num_regs);
+       struct reg *reg_list = calloc(num_regs, sizeof(struct reg));
        struct mips32_core_reg *arch_info = malloc(sizeof(struct 
mips32_core_reg) * num_regs);
        int i;
 
diff --git a/src/target/openrisc/or1k.c b/src/target/openrisc/or1k.c
index f26a016..5852fc7 100644
--- a/src/target/openrisc/or1k.c
+++ b/src/target/openrisc/or1k.c
@@ -513,7 +513,7 @@ static struct reg_cache *or1k_build_reg_cache(struct target 
*target)
        struct or1k_common *or1k = target_to_or1k(target);
        struct reg_cache **cache_p = 
register_get_last_cache_p(&target->reg_cache);
        struct reg_cache *cache = malloc(sizeof(struct reg_cache));
-       struct reg *reg_list = malloc((or1k->nb_regs) * sizeof(struct reg));
+       struct reg *reg_list = calloc(or1k->nb_regs, sizeof(struct reg));
        struct or1k_core_reg *arch_info =
                malloc((or1k->nb_regs) * sizeof(struct or1k_core_reg));
        struct reg_feature *feature;

-- 

------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment 
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to