b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | From ad8c3353b8e482575ff2208182290cf35b624dde Mon Sep 17 00:00:00 2001 |
| 2 | From: Chris Leech <cleech@redhat.com> |
| 3 | Date: Wed, 5 Jun 2019 09:08:39 -0700 |
| 4 | Subject: [PATCH 1/1] Coverity scan fixes |
| 5 | |
| 6 | --- |
| 7 | iscsiuio/src/unix/libs/qedi.c | 2 +- |
| 8 | iscsiuio/src/unix/main.c | 3 +++ |
| 9 | libopeniscsiusr/idbm.c | 11 +++++------ |
| 10 | usr/idbm.c | 10 ++++------ |
| 11 | usr/initiator.c | 2 +- |
| 12 | usr/iscsid.c | 2 +- |
| 13 | 6 files changed, 15 insertions(+), 15 deletions(-) |
| 14 | |
| 15 | --- a/iscsiuio/src/unix/libs/qedi.c |
| 16 | +++ b/iscsiuio/src/unix/libs/qedi.c |
| 17 | @@ -1030,7 +1030,7 @@ static int qedi_read(nic_t *nic, packet_ |
| 18 | |
| 19 | LOG_DEBUG(PFX "%s:hw_prod %d bd_prod %d, rx_pkt_idx %d, rxlen %d", |
| 20 | nic->log_name, hw_prod, bd_prod, rx_bd->rx_pkt_index, len); |
| 21 | - LOG_DEBUG(PFX "%s: sw_con %d bd_cons %d num BD %d", |
| 22 | + LOG_DEBUG(PFX "%s: sw_con %d bd_cons %d num BD %lu", |
| 23 | nic->log_name, sw_cons, bd_cons, QEDI_NUM_RX_BD); |
| 24 | |
| 25 | if (bd_cons != bd_prod) { |
| 26 | --- a/iscsiuio/src/unix/main.c |
| 27 | +++ b/iscsiuio/src/unix/main.c |
| 28 | @@ -391,6 +391,9 @@ int main(int argc, char *argv[]) |
| 29 | sigaddset(&set, SIGTERM); |
| 30 | sigaddset(&set, SIGUSR1); |
| 31 | rc = pthread_sigmask(SIG_SETMASK, &set, NULL); |
| 32 | + if (rc != 0) { |
| 33 | + LOG_ERR("Failed to set thread signal mask"); |
| 34 | + } |
| 35 | |
| 36 | /* Spin off the signal handling thread */ |
| 37 | pthread_attr_init(&attr); |
| 38 | --- a/libopeniscsiusr/idbm.c |
| 39 | +++ b/libopeniscsiusr/idbm.c |
| 40 | @@ -321,12 +321,11 @@ int _idbm_lock(struct iscsi_context *ctx |
| 41 | return 0; |
| 42 | } |
| 43 | |
| 44 | - if (access(LOCK_DIR, F_OK) != 0) { |
| 45 | - if (mkdir(LOCK_DIR, 0660) != 0) { |
| 46 | - _error(ctx, "Could not open %s: %d %s", LOCK_DIR, errno, |
| 47 | - _strerror(errno, strerr_buff)); |
| 48 | - return LIBISCSI_ERR_IDBM; |
| 49 | - } |
| 50 | + if (((mkdir(LOCK_DIR, 0660) != 0) && (errno != EEXIST)) || |
| 51 | + (access(LOCK_DIR, F_OK) != 0)) { |
| 52 | + _error(ctx, "Could not open %s: %d %s", LOCK_DIR, errno, |
| 53 | + _strerror(errno, strerr_buff)); |
| 54 | + return LIBISCSI_ERR_IDBM; |
| 55 | } |
| 56 | |
| 57 | fd = open(LOCK_FILE, O_RDWR | O_CREAT, 0666); |
| 58 | --- a/usr/idbm.c |
| 59 | +++ b/usr/idbm.c |
| 60 | @@ -1439,12 +1439,10 @@ int idbm_lock(void) |
| 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | - if (access(LOCK_DIR, F_OK) != 0) { |
| 65 | - if (mkdir(LOCK_DIR, 0660) != 0) { |
| 66 | - log_error("Could not open %s: %s", LOCK_DIR, |
| 67 | - strerror(errno)); |
| 68 | - return ISCSI_ERR_IDBM; |
| 69 | - } |
| 70 | + if (((mkdir(LOCK_DIR, 0660) != 0) && (errno != EEXIST)) || |
| 71 | + (access(LOCK_DIR, F_OK) != 0)) { |
| 72 | + log_error("Could not open %s: %s", LOCK_DIR, strerror(errno)); |
| 73 | + return ISCSI_ERR_IDBM; |
| 74 | } |
| 75 | |
| 76 | fd = open(LOCK_FILE, O_RDWR | O_CREAT, 0666); |
| 77 | --- a/usr/iscsid.c |
| 78 | +++ b/usr/iscsid.c |
| 79 | @@ -495,8 +495,8 @@ int main(int argc, char *argv[]) |
| 80 | log_close(log_pid); |
| 81 | exit(ISCSI_ERR); |
| 82 | } |
| 83 | + close(fd); |
| 84 | } |
| 85 | - close(fd); |
| 86 | |
| 87 | if ((control_fd = ipc->ctldev_open()) < 0) { |
| 88 | log_close(log_pid); |
| 89 | --- a/usr/initiator.c |
| 90 | +++ b/usr/initiator.c |
| 91 | @@ -580,7 +580,7 @@ __session_conn_reopen(iscsi_conn_t *conn |
| 92 | int redirected) |
| 93 | { |
| 94 | iscsi_session_t *session = conn->session; |
| 95 | - uint32_t delay; |
| 96 | + uint32_t delay = 0; |
| 97 | |
| 98 | log_debug(1, "re-opening session %d (reopen_cnt %d)", session->id, |
| 99 | session->reopen_cnt); |