target: Make profiling function more readable 06/1606/3
authorHsiangkai Wang <hsiangkai@gmail.com>
Fri, 30 Aug 2013 05:18:54 +0000 (13:18 +0800)
committerSpencer Oliver <spen@spen-soft.co.uk>
Fri, 13 Sep 2013 19:36:33 +0000 (19:36 +0000)
Change variable name 'length' to 'numBuckets'.  It is more readable.

Change-Id: I913cba0746f887adf6da401a46cd5e9ea88d2c6d
Signed-off-by: Hsiangkai Wang <hsiangkai@gmail.com>
Reviewed-on: http://openocd.zylin.com/1606
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
src/target/target.c

index d34e14418ff608b2dfe805edcc136b6cf6a684f2..11b12e5e84d4c20eb4e97dd1900571e09bdc5350 100644 (file)
@@ -3391,19 +3391,19 @@ static void writeGmon(uint32_t *samples, uint32_t sampleNum, const char *filenam
        assert(addressSpace >= 2);
 
        static const uint32_t maxBuckets = 16 * 1024; /* maximum buckets. */
-       uint32_t length = addressSpace;
-       if (length > maxBuckets)
-               length = maxBuckets;
-       int *buckets = malloc(sizeof(int)*length);
+       uint32_t numBuckets = addressSpace;
+       if (numBuckets > maxBuckets)
+               numBuckets = maxBuckets;
+       int *buckets = malloc(sizeof(int) * numBuckets);
        if (buckets == NULL) {
                fclose(f);
                return;
        }
-       memset(buckets, 0, sizeof(int) * length);
+       memset(buckets, 0, sizeof(int) * numBuckets);
        for (i = 0; i < sampleNum; i++) {
                uint32_t address = samples[i];
                long long a = address - min;
-               long long b = length - 1;
+               long long b = numBuckets - 1;
                long long c = addressSpace - 1;
                int index_t = (a * b) / c; /* danger!!!! int32 overflows */
                buckets[index_t]++;
@@ -3412,7 +3412,7 @@ static void writeGmon(uint32_t *samples, uint32_t sampleNum, const char *filenam
        /* append binary memory gmon.out &profile_hist_hdr ((char*)&profile_hist_hdr + sizeof(struct gmon_hist_hdr)) */
        writeLong(f, min);                      /* low_pc */
        writeLong(f, max);                      /* high_pc */
-       writeLong(f, length);           /* # of samples */
+       writeLong(f, numBuckets);       /* # of buckets */
        writeLong(f, 100);                      /* KLUDGE! We lie, ca. 100Hz best case. */
        writeString(f, "seconds");
        for (i = 0; i < (15-strlen("seconds")); i++)
@@ -3421,9 +3421,9 @@ static void writeGmon(uint32_t *samples, uint32_t sampleNum, const char *filenam
 
        /*append binary memory gmon.out profile_hist_data (profile_hist_data + profile_hist_hdr.hist_size) */
 
-       char *data = malloc(2 * length);
+       char *data = malloc(2 * numBuckets);
        if (data != NULL) {
-               for (i = 0; i < length; i++) {
+               for (i = 0; i < numBuckets; i++) {
                        int val;
                        val = buckets[i];
                        if (val > 65535)
@@ -3432,7 +3432,7 @@ static void writeGmon(uint32_t *samples, uint32_t sampleNum, const char *filenam
                        data[i * 2 + 1] = (val >> 8) & 0xff;
                }
                free(buckets);
-               writeData(f, data, length * 2);
+               writeData(f, data, numBuckets * 2);
                free(data);
        } else
                free(buckets);

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)