Change all liblvm2app API calls to return void and note use of lvm_errno.
PATCH 1/1 Change all liblvm2app API calls to return void and note use of lvm_errno.
Remove the return 'int' value for most of liblvm2app calls. We now have lvm_errno and lvm_errmsg. Update test/api/vgtest.c
Signed-off-by Dave Wysochanski <[email protected]>
--- liblvm/lvm.h | 27 ++++++++----------------- liblvm/lvm_base.c | 5 ++- liblvm/lvm_vg.c | 55 ++++++++++++++++++++++++++++------------------------ test/api/vgtest.c | 9 +++---- 4 files changed, 46 insertions(+), 50 deletions(-)
liblvm/lvm.h +9 -18
@@ -69,7 +69,7 @@ void lvm_destroy(lvm_t libh);* \param libh * Handle obtained from lvm_create. */ -int lvm_reload_config (lvm_t libh); +void lvm_reload_config (lvm_t libh);/** * Return stored error no describing last LVM API error.
@@ -110,8 +110,8 @@ const char *lvm_errmsg(lvm_t libh);* \param libh * Handle obtained from lvm_create. * -* \return A VG handle with error code set appropriately. -* FIXME: Update error handling description after errno and logging patches +* \return A VG handle or NULL upon failure. Use lvm_errno() to verify +* success or failure and check the failure code. */ vg_t *lvm_vg_create (lvm_t libh,const char *vg_name);
@@ -128,10 +128,8 @@ vg_t *lvm_vg_create(lvm_t libh, const char *vg_name);* * \param device * Name of device to add to VG. -* -* \return Status code of 1 (success) or 0 (failure). */ -int lvm_vg_extend (vg_t *vg,const char *device); +void lvm_vg_extend (vg_t *vg,const char *device);/** * Set the extent size of a VG.
@@ -146,10 +144,8 @@ int lvm_vg_extend(vg_t *vg, const char *device);* * \param new_size * New extent size to set (in sectors). -* -* \return Status code of 1 (success) or 0 (failure). */ -int lvm_vg_set_extent_size (vg_t *vg,uint32_t new_size); +void lvm_vg_set_extent_size (vg_t *vg,uint32_t new_size);/** * Write a VG to disk.
@@ -160,10 +156,8 @@ int lvm_vg_set_extent_size(vg_t *vg, uint32_t new_size);* * \param vg * VG handle obtained from lvm_vg_create. -* -* \return Status code of 1 (success) or 0 (failure). */ -int lvm_vg_write (vg_t *vg); +void lvm_vg_write (vg_t *vg);/** * Remove a VG from the system.
@@ -173,10 +167,8 @@ int lvm_vg_write(vg_t *vg);* * \param vg * VG handle obtained from lvm_vg_create. -* -* \return Status code of 1 (success) or 0 (failure). */ -int lvm_vg_remove (vg_t *vg); +void lvm_vg_remove (vg_t *vg);/** * Close a VG opened with lvm_vg_create
@@ -185,9 +177,8 @@ int lvm_vg_remove(vg_t *vg);* * \param vg * VG handle obtained from lvm_vg_create. -* -* \return Status code of 1 (success) or 0 (failure). +* FIXME: note the handle can be obtained from vg_read once vg_read exported */ -int lvm_vg_close (vg_t *vg); +void lvm_vg_close (vg_t *vg);#endif /* _LIB_LVM_H */
liblvm/lvm_base.c +3 -2
@@ -65,10 +65,11 @@ void lvm_destroy(lvm_t libh)destroy_toolcontext ((struct cmd_context *)libh); } -int lvm_reload_config (lvm_t libh) +void lvm_reload_config (lvm_t libh) {/* FIXME: re-init locking needed here? */ -return refresh_toolcontext ((struct cmd_context *)libh); +if (!refresh_toolcontext ((struct cmd_context *)libh)) +log_error ("Error re-reading configuration\n" ); }int lvm_errno (lvm_t libh)
liblvm/lvm_vg.c +30 -25
89 lines not on this page · raw message
test/api/vgtest.c +4 -5
@@ -30,7 +30,6 @@ uint64_t size = 1024;int main (int argc,char *argv[]) { -int status;/* FIXME: input vgname, etc from cmdline */ /* FIXME: make the below messages verbose-only and print PASS/FAIL*/
@@ -50,7 +49,7 @@ int main(int argc, char *argv[]) }printf ("Extending VG %s\n" , vg_name); - status =lvm_vg_extend (vg, device); +lvm_vg_extend (vg, device);if (lvm_errno (handle)) {fprintf (stderr,"Error extending volume group %s " "with device %s\n" , vg_name, device);
@@ -59,7 +58,7 @@ int main(int argc, char *argv[]) }printf ("Setting VG %s extent_size to %" PRIu64"\n" , vg_name, size); - status =lvm_vg_set_extent_size (vg, size); +lvm_vg_set_extent_size (vg, size);if (lvm_errno (handle)) { fprintf(stderr, "Can not set physical extent " "size '%"PRIu64"' for '%s'\n",
@@ -69,7 +68,7 @@ int main(int argc, char *argv[]) }printf ("Committing VG %s to disk\n" , vg_name); - status =lvm_vg_write (vg); +lvm_vg_write (vg);if (lvm_errno (handle)) { fprintf(stderr, "Creation of volume group '%s' on " "device '%s' failed\n",
@@ -79,7 +78,7 @@ int main(int argc, char *argv[]) }printf ("Removing VG %s from system\n" , vg_name); - status =lvm_vg_remove (vg); +lvm_vg_remove (vg);if (lvm_errno (handle)) {fprintf (stderr,"Revmoval of volume group '%s' failed\n" , vg_name);
Signature · 1 line
1.6.0.6
PATCH 1/1 Change all liblvm2app API calls to return void and note use of lvm_errno.
Quoted 3 lines · Dave Wysochanski
Remove the return 'int' value for most of liblvm2app calls. We now have
lvm_errnoandlvm_errmsg. Updatetest/api/vgtest.c
Withdrawing this patch for now.