Revision fc19f8a0 qemu-nbd.c
b/qemu-nbd.c | ||
---|---|---|
186 | 186 |
* modprobe nbd max_part=63 |
187 | 187 |
*/ |
188 | 188 |
nbd = open(device, O_RDWR); |
189 |
if (nbd != -1) {
|
|
189 |
if (nbd >= 0) {
|
|
190 | 190 |
close(nbd); |
191 | 191 |
} |
192 | 192 |
return NULL; |
... | ... | |
203 | 203 |
pthread_t show_parts_thread; |
204 | 204 |
|
205 | 205 |
sock = unix_socket_outgoing(sockpath); |
206 |
if (sock == -1) {
|
|
206 |
if (sock < 0) {
|
|
207 | 207 |
goto out; |
208 | 208 |
} |
209 | 209 |
|
210 | 210 |
ret = nbd_receive_negotiate(sock, NULL, &nbdflags, |
211 | 211 |
&size, &blocksize); |
212 |
if (ret == -1) {
|
|
212 |
if (ret < 0) {
|
|
213 | 213 |
goto out; |
214 | 214 |
} |
215 | 215 |
|
216 | 216 |
fd = open(device, O_RDWR); |
217 |
if (fd == -1) {
|
|
217 |
if (fd < 0) {
|
|
218 | 218 |
/* Linux-only, we can use %m in printf. */ |
219 | 219 |
fprintf(stderr, "Failed to open %s: %m", device); |
220 | 220 |
goto out; |
221 | 221 |
} |
222 | 222 |
|
223 | 223 |
ret = nbd_init(fd, sock, nbdflags, size, blocksize); |
224 |
if (ret == -1) {
|
|
224 |
if (ret < 0) {
|
|
225 | 225 |
goto out; |
226 | 226 |
} |
227 | 227 |
|
... | ... | |
268 | 268 |
|
269 | 269 |
int fd = accept(server_fd, (struct sockaddr *)&addr, &addr_len); |
270 | 270 |
nbd_started = true; |
271 |
if (fd != -1 && nbd_client_new(exp, fd, nbd_client_closed)) {
|
|
271 |
if (fd >= 0 && nbd_client_new(exp, fd, nbd_client_closed)) {
|
|
272 | 272 |
nb_fds++; |
273 | 273 |
} |
274 | 274 |
} |
... | ... | |
410 | 410 |
|
411 | 411 |
if (disconnect) { |
412 | 412 |
fd = open(argv[optind], O_RDWR); |
413 |
if (fd == -1)
|
|
413 |
if (fd < 0) {
|
|
414 | 414 |
err(EXIT_FAILURE, "Cannot open %s", argv[optind]); |
415 |
|
|
415 |
} |
|
416 | 416 |
nbd_disconnect(fd); |
417 | 417 |
|
418 | 418 |
close(fd); |
... | ... | |
427 | 427 |
pid_t pid; |
428 | 428 |
int ret; |
429 | 429 |
|
430 |
if (qemu_pipe(stderr_fd) == -1) {
|
|
430 |
if (qemu_pipe(stderr_fd) < 0) {
|
|
431 | 431 |
err(EXIT_FAILURE, "Error setting up communication pipe"); |
432 | 432 |
} |
433 | 433 |
|
... | ... | |
441 | 441 |
|
442 | 442 |
/* Temporarily redirect stderr to the parent's pipe... */ |
443 | 443 |
dup2(stderr_fd[1], STDERR_FILENO); |
444 |
if (ret == -1) {
|
|
444 |
if (ret < 0) {
|
|
445 | 445 |
err(EXIT_FAILURE, "Failed to daemonize"); |
446 | 446 |
} |
447 | 447 |
|
... | ... | |
459 | 459 |
while ((ret = read(stderr_fd[0], buf, 1024)) > 0) { |
460 | 460 |
errors = true; |
461 | 461 |
ret = qemu_write_full(STDERR_FILENO, buf, ret); |
462 |
if (ret == -1) {
|
|
462 |
if (ret < 0) {
|
|
463 | 463 |
exit(EXIT_FAILURE); |
464 | 464 |
} |
465 | 465 |
} |
466 |
if (ret == -1) {
|
|
466 |
if (ret < 0) {
|
|
467 | 467 |
err(EXIT_FAILURE, "Cannot read from daemon"); |
468 | 468 |
} |
469 | 469 |
|
... | ... | |
504 | 504 |
fd = tcp_socket_incoming(bindto, port); |
505 | 505 |
} |
506 | 506 |
|
507 |
if (fd == -1) {
|
|
507 |
if (fd < 0) {
|
|
508 | 508 |
return 1; |
509 | 509 |
} |
510 | 510 |
|
Also available in: Unified diff