qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Several sheepdog functions mix up -1 and -errno in return values
@ 2015-02-12 14:01 Markus Armbruster
  2015-02-13  3:45 ` [Qemu-devel] [PATCH] sheepdog: fix confused " Liu Yuan
  0 siblings, 1 reply; 10+ messages in thread
From: Markus Armbruster @ 2015-02-12 14:01 UTC (permalink / raw)
  To: mitake.hitoshi, namei.unix, sheepdog; +Cc: kwolf, qemu-devel

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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-02-26  8:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-12 14:01 [Qemu-devel] Several sheepdog functions mix up -1 and -errno in return values Markus Armbruster
2015-02-13  3:45 ` [Qemu-devel] [PATCH] sheepdog: fix confused " Liu Yuan
2015-02-13  3:49   ` Liu Yuan
2015-02-16 11:56   ` Kevin Wolf
2015-02-18  3:52     ` Liu Yuan
2015-02-18  8:35   ` Markus Armbruster
2015-02-25  1:39     ` Liu Yuan
2015-02-25  9:35       ` Markus Armbruster
2015-02-26  3:54         ` Liu Yuan
2015-02-26  7:50           ` Markus Armbruster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).