Skip to content

Commit 213ed9f

Browse files
committed
PVS-Studio fixes. closes gh-50
1 parent 764adca commit 213ed9f

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

tnt/tnt_auth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ tnt_auth_raw(struct tnt_stream *s, const char *user, int ulen,
7676
v[3].iov_len = ulen;
7777
body_start = data;
7878
data = mp_encode_uint(data, TNT_TUPLE);
79+
char salt[64], scramble[TNT_SCRAMBLE_SIZE];
7980
if (!guest) {
8081
data = mp_encode_array(data, 2);
8182
data = mp_encode_str(data, "chap-sha1", strlen("chap-sha1"));
8283
data = mp_encode_strl(data, TNT_SCRAMBLE_SIZE);
83-
char salt[64], scramble[TNT_SCRAMBLE_SIZE];
8484
base64_decode(base64_salt, TNT_SALT_SIZE, salt, 64);
8585
tnt_scramble_prepare(scramble, salt, pass, plen);
8686
v[5].iov_base = scramble;

tnt/tnt_io.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ tnt_io_resolve(struct sockaddr_in *addr,
6868
addr->sin_family = AF_INET;
6969
addr->sin_port = htons(port);
7070
struct addrinfo *addr_info = NULL;
71-
if (getaddrinfo(hostname, NULL, NULL, &addr_info) == 0) {
71+
if (getaddrinfo(hostname, NULL, NULL, &addr_info) == 0 &&
72+
addr_info != NULL) {
7273
memcpy(&addr->sin_addr,
7374
(void*)&((struct sockaddr_in *)addr_info->ai_addr)->sin_addr,
7475
sizeof(addr->sin_addr));

tnt/tnt_object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ ssize_t tnt_object_vformat(struct tnt_stream *s, const char *fmt, va_list vl)
332332
if ((rv = tnt_object_add_map(s, 0)) == -1)
333333
return -1;
334334
result += rv;
335-
} if (f[0] == ']' || f[0] == '}') {
335+
} else if (f[0] == ']' || f[0] == '}') {
336336
if ((rv = tnt_object_container_close(s)) == -1)
337337
return -1;
338338
result += rv;

tnt/tnt_request.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,12 @@ tnt_request_writeout(struct tnt_stream *s, struct tnt_request *req,
312312
v[v_sz++].iov_len = pos - begin;
313313
}
314314
mp_encode_map(map, nd);
315-
size_t plen = 0; nd = 0;
315+
316+
size_t plen = 0;
316317
for (int i = 1; i < v_sz; ++i) plen += v[i].iov_len;
317-
nd = mp_sizeof_luint32(plen);
318-
v[0].iov_base -= nd;
319-
v[0].iov_len += nd;
318+
size_t hlen = mp_sizeof_luint32(plen);
319+
v[0].iov_base -= hlen;
320+
v[0].iov_len += hlen;
320321
mp_encode_luint32(v[0].iov_base, plen);
321322
ssize_t rv = s->writev(s, v, v_sz);
322323
if (rv == -1)

tnt/tnt_schema.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ void tnt_schema_flush(struct tnt_schema *obj) {
300300

301301
void tnt_schema_free(struct tnt_schema *obj) {
302302
if (obj == NULL)
303-
return NULL;
303+
return;
304304
tnt_schema_space_free(obj->space_hash);
305305
mh_assoc_delete(obj->space_hash);
306306
}

0 commit comments

Comments
 (0)