qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Several sheepdog functions mix up -1 and -errno in return v


From: Markus Armbruster
Subject: [Qemu-devel] Several sheepdog functions mix up -1 and -errno in return values
Date: Thu, 12 Feb 2015 15:01:26 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Two common conventions for functions returning int that may fail:

1. Return non-negative value on success, -1 value on failure.

2. Return non-negative value on success, a negative errno error code on
   failure.

Both work.  But mixing them in the same function is not a good idea.

Suspicious functions in block/sheepdog.c include:

* read_write_object()

  May return 0, -EIO or the value of do_req().  do_req() returns
  srco.ret.  do_co_req() may set it to the value of send_co_req().  I
  don't think that one returns -errno.

* do_sd_create()

  May return 0, -EIO or the value of connect_to_sdog().  I don't think
  the latter returns -errno.

I suspect there are more.  Please audit the file for this kind of
mistake.  Good opportunity to document for each function what it's
supposed to return.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]