jtag: linuxgpiod: drop extra parenthesis
[openocd.git] / src / pld / raw_bit.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2
3 /***************************************************************************
4 * Copyright (C) 2022 by Daniel Anselmi *
5 * danselmi@gmx.ch *
6 ***************************************************************************/
7
8 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif
11
12 #include "raw_bit.h"
13 #include "pld.h"
14
15 #include <helper/system.h>
16 #include <helper/log.h>
17
18
19 int cpld_read_raw_bit_file(struct raw_bit_file *bit_file, const char *filename)
20 {
21 FILE *input_file = fopen(filename, "rb");
22
23 if (!input_file) {
24 LOG_ERROR("Couldn't open %s: %s", filename, strerror(errno));
25 return ERROR_PLD_FILE_LOAD_FAILED;
26 }
27
28 fseek(input_file, 0, SEEK_END);
29 long length = ftell(input_file);
30 fseek(input_file, 0, SEEK_SET);
31
32 if (length < 0) {
33 fclose(input_file);
34 LOG_ERROR("Failed to get length of file %s: %s", filename, strerror(errno));
35 return ERROR_PLD_FILE_LOAD_FAILED;
36 }
37 bit_file->length = (size_t)length;
38
39 bit_file->data = malloc(bit_file->length);
40 if (!bit_file->data) {
41 fclose(input_file);
42 LOG_ERROR("Out of memory");
43 return ERROR_PLD_FILE_LOAD_FAILED;
44 }
45
46 size_t read_count = fread(bit_file->data, sizeof(char), bit_file->length, input_file);
47 fclose(input_file);
48 if (read_count != bit_file->length) {
49 free(bit_file->data);
50 bit_file->data = NULL;
51 return ERROR_PLD_FILE_LOAD_FAILED;
52 }
53
54 return ERROR_OK;
55 }

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)