Discussion:
unknown
1970-01-01 00:00:00 UTC
Permalink
I would use '-1' rather than a named constant so that it's very obvious
that this value is very special when it shows up in an argument list,
but that's just a matter of personal preference :)

The patch looks good to me.

Christophe
LSM_CAP_VOLUMES =3D 20, /**< L=
ist volumes */
LSM_CAP_VOLUME_CREATE =3D 21, /**< C=
reate volumes */
LSM_CAP_VOLUME_RESIZE =3D 22, /**< R=
esize volumes */
diff --git a/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interfa=
ce.h b/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h
index 1deab9a..71a6579 100644
--- a/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h
+++ b/c_binding/include/libstoragemgmt/libstoragemgmt_plug_interface.h
@@ -1226,13 +1226,12 @@ int LSM_DLL_EXPORT lsm_capability_set(lsm_storage=
_capabilities *cap, lsm_capabil
* Sets 1 or more capabilities with the same value v
list
+ * with LSM_CAP_SENTINEL)
*/
int LSM_DLL_EXPORT lsm_capability_set_n( lsm_storage_capabilities *cap,
- lsm_capability_value_type v,
- uint32_t number, ... );
+ lsm_capability_value_type v, ...=
);
=20
/**
* Allocated storage for capabilities
diff --git a/c_binding/lsm_datatypes.cpp b/c_binding/lsm_datatypes.cpp
index 4e8795a..f826852 100644
--- a/c_binding/lsm_datatypes.cpp
+++ b/c_binding/lsm_datatypes.cpp
@@ -1571,35 +1571,29 @@ int lsm_capability_set(lsm_storage_capabilities *=
cap, lsm_capability_type t,
}
=20
int lsm_capability_set_n( lsm_storage_capabilities *cap,
- lsm_capability_value_type v, uint32_t nu=
mber,
+ lsm_capability_value_type v,
... )
{
- uint32_t i =3D 0;
int rc =3D LSM_ERR_OK;
+ int index =3D 0;
=20
if( !LSM_IS_CAPABILITIY(cap) ) {
return LSM_ERR_INVALID_CAPABILITY;
}
=20
- if( number ) {
- va_list var_arg;
+ va_list var_arg;
+ va_start(var_arg, v);
=20
- va_start(var_arg, number);
-
- for( i =3D 0; i < number; ++i ) {
- int index =3D va_arg(var_arg, int);
-
- if( index < (int)cap->len ) {
- cap->cap[index] =3D v;
- } else {
- rc =3D LSM_ERR_INVALID_ARGUMENT;
- break;
- }
+ while( (index =3D va_arg(var_arg, int)) !=3D LSM_CAP_SET_N_SENTINEL =
) {
+ if( index < (int)cap->len ) {
+ cap->cap[index] =3D v;
+ } else {
+ rc =3D LSM_ERR_INVALID_ARGUMENT;
+ break;
}
-
- va_end(var_arg);
}
=20
+ va_end(var_arg);
return rc;
}
=20
diff --git a/plugin/simc/simc_lsmplugin.c b/plugin/simc/simc_lsmplugin.c
index b39d7ed..36d43d2 100644
--- a/plugin/simc/simc_lsmplugin.c
+++ b/plugin/simc/simc_lsmplugin.c
@@ -334,7 +334,7 @@ static int cap(lsm_plugin_ptr c, lsm_system *system,
*cap =3D lsm_capability_record_alloc(NULL);
=20
if( *cap ) {
- rc =3D lsm_capability_set_n(*cap, LSM_CAPABILITY_SUPPORTED, 43,
+ rc =3D lsm_capability_set_n(*cap, LSM_CAPABILITY_SUPPORTED,
LSM_CAP_VOLUMES,
LSM_CAP_VOLUME_CREATE,
LSM_CAP_VOLUME_RESIZE,
@@ -377,7 +377,8 @@ static int cap(lsm_plugin_ptr c, lsm_system *system,
LSM_CAP_EXPORT_AUTH,
LSM_CAP_EXPORTS,
LSM_CAP_EXPORT_FS,
- LSM_CAP_EXPORT_REMOVE
+ LSM_CAP_EXPORT_REMOVE,
+ LSM_CAP_SET_N_SENTINEL
);
=20
if( LSM_ERR_OK !=3D rc ) {
diff --git a/test/tester.c b/test/tester.c
index e0f09aa..ac250c6 100644
--- a/test/tester.c
+++ b/test/tester.c
@@ -2125,7 +2125,7 @@ START_TEST(test_capability)
fail_unless(cap !=3D NULL);
=20
if( cap ) {
- G(rc, lsm_capability_set_n, cap, LSM_CAPABILITY_SUPPORTED, 43,
+ G(rc, lsm_capability_set_n, cap, LSM_CAPABILITY_SUPPORTED,
LSM_CAP_VOLUMES,
LSM_CAP_VOLUME_CREATE,
LSM_CAP_VOLUME_RESIZE,
@@ -2168,7 +2168,8 @@ START_TEST(test_capability)
LSM_CAP_EXPORT_AUTH,
LSM_CAP_EXPORTS,
LSM_CAP_EXPORT_FS,
- LSM_CAP_EXPORT_REMOVE
+ LSM_CAP_EXPORT_REMOVE,
+ LSM_CAP_SET_N_SENTINEL
);
=20
G(rc, lsm_capability_set, cap, LSM_CAP_EXPORTS,
--=20
1.8.2.1
=20
=20
-------------------------------------------------------------------------=
-----
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Libstoragemgmt-devel mailing list
https://lists.sourceforge.net/lists/listinfo/libstoragemgmt-devel
--nFreZHaLTZJo0R7j
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCAAGBQJT3SEGAAoJEKnYwhQprGyCwX4P/A+sKc8TMvwPR/QhprLObEqM
OtKEbHZd9tSwuTKu/gPdQx0VmeF/w12e+6yaOfs5H/tiUysrYfrJ/hpzvTnGgbzh
GuAMKB0NG3lgXwwX5M71ES9iRk8c/6hPOfOJBNmKbQ+X3YUni22tVXojAEMIYmYD
f4GMaFQVnTRNexPuw9bsaT3EOvGTpI+hagTG4csRK6RbHVwK/Z8h0shBeHre1jcP
FA/7rPugjkcwWVmA3jSpzbRuoiP9gVMH0jRIYD6ZA4tBRFxWgQpru7O4ZyHbWu/Y
MeuKAFzW2tzYEdXj9R/N8DGYhEwqyQraPqC3XGvEUoqWt+sipRYd/kjbtEJivB1i
YeNtlu9FHELraQ56pdQuzJ3So+6PpLyPIiopSOASHRzftPrh6hS7Tiu1zF3tymLE
IwwOH161swfd632R3o0Ho3I259CI4PGcwaAtQUucTiNH22JY4rmo8wYMEslSJg4n
ORb8eo8hJHH5EayTQxoJ60zkShL106VaButWqv6yfxibD5CQZ/xFg/KoG+SL+mOD
VRgzgKbZ3S/WzE+m8nlMlkF5jd1YyS68GWfpwL8l6KA8g3SM+tSCIb8HdUpxaNLx
SrOc0RY1uhnCBxSFsavuF22fwJoBRR5P+s+/B5Lf6fLzGAU6Nq7LQiOAaGRZ1YmU
2ZuPKqYhWDpVexzEkrY9
=Ic71
-----END PGP SIGNATURE-----

--nFreZHaLTZJo0R7j--

Loading...