pld/gowin: move pointer deref after NULL check

Move pointer deref after NULL check.
Found by cppcheck.

Change-Id: Ic1b197fa43fa800cfec631614574dda46b137597
Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
Reviewed-on: https://review.openocd.org/c/openocd/+/9500
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
Reviewed-by: Daniel Anselmi <danselmi@gmx.ch>
This commit is contained in:
Mark O'Donovan
2026-02-24 20:41:43 +00:00
committed by Antonio Borneo
parent 0e41ac862d
commit bd17a59fd1

View File

@@ -172,11 +172,11 @@ static int gowin_read_fs_file(struct gowin_bit_file *bit_file, const char *filen
static int gowin_read_file(struct gowin_bit_file *bit_file, const char *filename, bool *is_fs) static int gowin_read_file(struct gowin_bit_file *bit_file, const char *filename, bool *is_fs)
{ {
memset(bit_file, 0, sizeof(struct gowin_bit_file));
if (!filename || !bit_file) if (!filename || !bit_file)
return ERROR_COMMAND_SYNTAX_ERROR; return ERROR_COMMAND_SYNTAX_ERROR;
memset(bit_file, 0, sizeof(struct gowin_bit_file));
const char *file_suffix_pos = strrchr(filename, '.'); const char *file_suffix_pos = strrchr(filename, '.');
if (!file_suffix_pos) { if (!file_suffix_pos) {
LOG_ERROR("Unable to detect filename suffix"); LOG_ERROR("Unable to detect filename suffix");