Zach Welch <zw@superlucidity.net>fix unused return value warnings (3 of 4)
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 21 Apr 2009 05:35:10 +0000 (05:35 +0000)
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 21 Apr 2009 05:35:10 +0000 (05:35 +0000)
git-svn-id: svn://svn.berlios.de/openocd/trunk@1482 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/target/target.c

index 40a2dc93ff46aabd44ddb1522fe3d52e45de8aae..ab82389432acbbe73b0f58d100a3ccba9c3cc635 100644 (file)
@@ -2491,20 +2491,27 @@ int handle_virt2phys_command(command_context_t *cmd_ctx, char *cmd, char **args,
        return retval;
 }
 
+static void writeData(FILE *f, const void *data, size_t len)
+{
+       size_t written = fwrite(data, len, 1, f);
+       if (written != len)
+               LOG_ERROR("failed to write %u bytes: %s", len, strerror(errno));
+}
+
 static void writeLong(FILE *f, int l)
 {
        int i;
        for (i=0; i<4; i++)
        {
                char c=(l>>(i*8))&0xff;
-               fwrite(&c, 1, 1, f);
+               writeData(f, &c, 1);
        }
 
 }
 
 static void writeString(FILE *f, char *s)
 {
-       fwrite(s, 1, strlen(s), f);
+       writeData(f, s, strlen(s));
 }
 
 /* Dump a gmon.out histogram file. */
@@ -2514,13 +2521,14 @@ static void writeGmon(u32 *samples, u32 sampleNum, char *filename)
        FILE *f=fopen(filename, "w");
        if (f==NULL)
                return;
-       fwrite("gmon", 1, 4, f);
+       writeString(f, "gmon");
        writeLong(f, 0x00000001); /* Version */
        writeLong(f, 0); /* padding */
        writeLong(f, 0); /* padding */
        writeLong(f, 0); /* padding */
 
-       fwrite("", 1, 1, f);  /* GMON_TAG_TIME_HIST */
+       u8 zero = 0;  /* GMON_TAG_TIME_HIST */
+       writeData(f, &zero, 1);
 
        /* figure out bucket size */
        u32 min=samples[0];
@@ -2569,9 +2577,7 @@ static void writeGmon(u32 *samples, u32 sampleNum, char *filename)
        writeLong(f, 64000000);         /* 64MHz */
        writeString(f, "seconds");
        for (i=0; i<(15-strlen("seconds")); i++)
-       {
-               fwrite("", 1, 1, f);    /* padding */
-       }
+               writeData(f, &zero, 1);
        writeString(f, "s");
 
        /*append binary memory gmon.out profile_hist_data (profile_hist_data + profile_hist_hdr.hist_size) */
@@ -2591,7 +2597,7 @@ static void writeGmon(u32 *samples, u32 sampleNum, char *filename)
                        data[i*2+1]=(val>>8)&0xff;
                }
                free(buckets);
-               fwrite(data, 1, length*2, f);
+               writeData(f, data, length * 2);
                free(data);
        } else
        {

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)