diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2015-05-05 16:23:18 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2015-05-05 16:23:18 +0200 |
commit | c377327fd756a2a7f0afad90dccbe97fe118206c (patch) | |
tree | 092faba2e448bda33ba7af2e4bf6df7734725c67 | |
parent | 890ba303b28be816ff00f464b6f3a6b000b5e6e2 (diff) | |
download | pcitool-c377327fd756a2a7f0afad90dccbe97fe118206c.tar.gz pcitool-c377327fd756a2a7f0afad90dccbe97fe118206c.tar.bz2 pcitool-c377327fd756a2a7f0afad90dccbe97fe118206c.tar.xz pcitool-c377327fd756a2a7f0afad90dccbe97fe118206c.zip |
Fix segmentation fault if requested register is not found
-rw-r--r-- | pcilib/register.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/pcilib/register.c b/pcilib/register.c index f10e29b..347bf7c 100644 --- a/pcilib/register.c +++ b/pcilib/register.c @@ -160,7 +160,7 @@ int pcilib_read_register(pcilib_t *ctx, const char *bank, const char *regname, p int reg; reg = pcilib_find_register(ctx, bank, regname); - if (reg < 0) { + if (reg == PCILIB_REGISTER_INVALID) { pcilib_error("Register (%s) is not found", regname); return PCILIB_ERROR_NOTFOUND; } @@ -291,7 +291,7 @@ int pcilib_write_register(pcilib_t *ctx, const char *bank, const char *regname, int reg; reg = pcilib_find_register(ctx, bank, regname); - if (reg < 0) { + if (reg == PCILIB_REGISTER_INVALID) { pcilib_error("Register (%s) is not found", regname); return PCILIB_ERROR_NOTFOUND; } |