]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
crush/builder: fix ENOENT when removing last bucket item
authorSage Weil <sage@redhat.com>
Wed, 9 Aug 2017 21:25:12 +0000 (17:25 -0400)
committerSage Weil <sage@redhat.com>
Sun, 13 Aug 2017 19:00:37 +0000 (15:00 -0400)
commitac85dcd35bb1788cf4adf10f1c57ef7e4bd546ea
tree765940dbb4e6e28d7499c7c242547f2fecaf0b92
parentfb2ba08e90f43b460987539168b984b837e4f9b6
crush/builder: fix ENOENT when removing last bucket item

We were decrementing size and then breaking out ENOENT condition check.
Fix by decrementing size only after we break out of the loop and verify
we found the item.

Fix a follow-on bug by avoiding realloc when we have 0 items left.  This case
was never exercised before due to the ENOENT issue; now we return explicitly.
It's really not necessary to realloc at all, probably, since these are very
small arrays, but in any case leaving a single item allocation there in place of
a 0-length allocation is fine.  (And the 0-length allocation behvaior on realloc
is undefined.. may either return a pointer or NULL.)

Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 5a982050c1daddee33bb2b5d63a5936723283765)
src/crush/builder.c