On 02/24/2014 05:39 PM, Jakub Hrozek wrote:
Hi,
The attached two patches are related to:
https://fedorahosted.org/sssd/ticket/2257
The first patch is included pretty much for completeness, as I noted
during development of the unit test, the blob type didn't handle any
default value.
The second patch directly addresses #2257. The previous code didn't
handle copying options well if the option was set to zero, because the
code followed logic like:
if (oldval) {
newval = oldval;
else {
newval = defval;
}
The patch implements Sumit's idea to provide a separate function for
copying default values and amend the generic copy function to only
create a copy using the current values.
Nack.
I think the approach is all right for this purpose, however have you
considered creating a flag "value_set" instead?
I see the following warnings in your unit test:
/home/pbrezina/workspace/sssd/src/tests/cmocka/test_dp_opts.c:58:35:
error: initializer element is not a constant expression [-Werror]
/home/pbrezina/workspace/sssd/src/tests/cmocka/test_dp_opts.c:58:35:
error: (near initialization for ‘test_def_opts[3].def_val.blob.length’)
[-Werror]
/home/pbrezina/workspace/sssd/src/tests/cmocka/test_dp_opts.c: In
function ‘opt_test_copy_default’:
/home/pbrezina/workspace/sssd/src/tests/cmocka/test_dp_opts.c:125:14:
error: cast discards ‘__attribute__((const))’ qualifier from pointer
target type [-Werror=cast-qual]
/home/pbrezina/workspace/sssd/src/tests/cmocka/test_dp_opts.c:131:14:
error: cast discards ‘__attribute__((const))’ qualifier from pointer
target type [-Werror=cast-qual]
/home/pbrezina/workspace/sssd/src/tests/cmocka/test_dp_opts.c: In
function ‘opt_test_copy_options’:
/home/pbrezina/workspace/sssd/src/tests/cmocka/test_dp_opts.c:171:14:
error: cast discards ‘__attribute__((const))’ qualifier from pointer
target type [-Werror=cast-qual]
/home/pbrezina/workspace/sssd/src/tests/cmocka/test_dp_opts.c: In
function ‘opt_test_get’:
/home/pbrezina/workspace/sssd/src/tests/cmocka/test_dp_opts.c:210:9:
error: variable ‘ret’ set but not used [-Werror=unused-but-set-variable]
/home/pbrezina/workspace/sssd/src/tests/cmocka/test_dp_opts.c: In
function ‘opt_test_getset_blob’:
/home/pbrezina/workspace/sssd/src/tests/cmocka/test_dp_opts.c:318:14:
error: cast discards ‘__attribute__((const))’ qualifier from pointer
target type [-Werror=cast-qual]