]> 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>
Sat, 12 Aug 2017 19:24:04 +0000 (15:24 -0400)
commit5a982050c1daddee33bb2b5d63a5936723283765
treefa8e8aeb56158ae6b14104d89cedba6a2a49bbd2
parent9c42597f096a3a08a552a7a14c6e5da415cf0037
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>
src/crush/builder.c