Skip to content

Commit c20c899

Browse files
committed
examples/telemetry-listen: coverity fixes
Coverity reported several issues. Signed-off-by: Hannes Reinecke <[email protected]>
1 parent 62ec078 commit c20c899

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

examples/telemetry-listen.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ static void save_telemetry(nvme_ctrl_t c)
5555
free(log);
5656
return;
5757
}
58-
log_size = (le16_to_cpu(log->dalb3) + 1) * NVME_LOG_TELEM_BLOCK_SIZE;
5958

6059
fd = open(buf, O_CREAT|O_WRONLY, S_IRUSR|S_IRGRP);
6160
if (fd < 0) {
@@ -77,8 +76,10 @@ static void check_telemetry(nvme_ctrl_t c, int ufd)
7776
{
7877
char buf[0x1000] = { 0 };
7978
char *p, *ptr;
79+
int len;
8080

81-
if (read(ufd, buf, sizeof(buf)) < 0)
81+
len = read(ufd, buf, sizeof(buf) - 1);
82+
if (len < 0)
8283
return;
8384

8485
ptr = buf;
@@ -140,7 +141,7 @@ int main()
140141
nvme_subsystem_for_each_ctrl(s, c)
141142
i++;
142143

143-
e = calloc(i, sizeof(e));
144+
e = calloc(i, sizeof(struct events));
144145
FD_ZERO(&fds);
145146
i = 0;
146147

0 commit comments

Comments
 (0)