[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 09/14] block/qcow2: qcow2_get_specific_info(): drop error pro
Re: [PATCH 09/14] block/qcow2: qcow2_get_specific_info(): drop error propagation
Thu, 17 Sep 2020 21:52:27 +0300
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.2.2
17.09.2020 19:32, Alberto Garcia wrote:
On Wed 09 Sep 2020 08:59:25 PM CEST, Vladimir Sementsov-Ogievskiy
+ * On success return true with bm_list set (probably to NULL, if no bitmaps),
" probably " ? :-)
I note this as "set to NULL" is not obvious thing (is it "unset" ? :).. And by "probably" I mean
"may be", i.e. NULL is just one of possible cases. Probably I use "probably" in a wrong way?
+ * on failure return false with errp set.
-Qcow2BitmapInfoList *qcow2_get_bitmap_info_list(BlockDriverState *bs,
- Error **errp)
+bool qcow2_get_bitmap_info_list(BlockDriverState *bs,
+ Qcow2BitmapInfoList **info_list, Error **errp)
BDRVQcow2State *s = bs->opaque;
- Qcow2BitmapInfoList *list = NULL;
- Qcow2BitmapInfoList **plist = &list;
So here 'list' points at NULL and 'plist' at &list.
Hmm, to be precise, list _is_ NULL (and points nowhere), and plist points to
- *plist = obj;
- plist = &obj->next;
In the original code 'plist' is updated when you add a new element, so
it always points at the end of the list. But 'list' is unchanged and it
still points at the first element.
So the caller receives a pointer to the first element.
+ *info_list = obj;
+ info_list = &obj->next;
But in the new code there is only one variable (passed by the caller),
which always points at the end of the list.
No: at first "*info_list = obj", we set the result which user will get, users
pointer now points to the first object in the list.
Then, at "info_list = &obj->next", we reassign info_list to another pointer: to "next"
field of first list item. So, all further "*info_list = obj" are note visible to the caller.
Actually, the logic is not changed, just instead of plist we use info_list, and instead of list - a variable which
should be defined in the caller. Look: in old code, first "*plist = obj" sets "list" variable, but
all further "*plist = obj" don't change "list" variable.
- Re: [PATCH 06/14] block/mirror: drop extra error propagation in commit_active_start(), (continued)
- [PATCH 08/14] blockjob: return status from block_job_set_speed(), Vladimir Sementsov-Ogievskiy, 2020/09/09
- [PATCH 12/14] block/qcow2: read_cache_sizes: return status value, Vladimir Sementsov-Ogievskiy, 2020/09/09
- [PATCH 09/14] block/qcow2: qcow2_get_specific_info(): drop error propagation, Vladimir Sementsov-Ogievskiy, 2020/09/09
- [PATCH 13/14] block/qcow2: qcow2_do_open: deal with errp, Vladimir Sementsov-Ogievskiy, 2020/09/09
- [PATCH 14/14] block/qed: bdrv_qed_do_open: deal with errp, Vladimir Sementsov-Ogievskiy, 2020/09/09