ehlo,
talloc_steal is a macro around function _talloc_steal_loc and returns the pointer that you pass it. It does not have any failure modes.
If the output value is ignored there are compiler warnings.
Example of warning src/util/util.c:503:164: warning: expression result unused [-Wunused-value] ({ __typeof__(internal_ctx) __talloc_steal_ret = (__typeof__(internal_ctx))_talloc_steal_loc((table),(internal_ctx), "../sssd/src/util/util.c" ":" "503"); __talloc_steal_ret; }); ^~~~~~~~~~~~~~~~~~ 1 warning generated.
I am opened to better solution of this warning.
LS
On Sat, 10 Jan 2015 18:12:26 +0100 Lukas Slebodnik lslebodn@redhat.com wrote:
ehlo,
talloc_steal is a macro around function _talloc_steal_loc and returns the pointer that you pass it. It does not have any failure modes.
If the output value is ignored there are compiler warnings.
Example of warning src/util/util.c:503:164: warning: expression result unused [-Wunused-value] ({ __typeof__(internal_ctx) __talloc_steal_ret = (__typeof__(internal_ctx))_talloc_steal_loc((table),(internal_ctx), "../sssd/src/util/util.c" ":" "503"); __talloc_steal_ret; }); ^~~~~~~~~~~~~~~~~~ 1 warning generated.
I am opened to better solution of this warning.
Maybe always assign to the variable being stolen ?
I do not remember if there is any case when a steal may cause the pointer to change (probably not) but the assignment would be safe and the compiler can optimize it out if the variable is not used further or internally no assignment ever happens.
Simo.
On 01/10/2015 06:12 PM, Lukas Slebodnik wrote:
ehlo,
talloc_steal is a macro around function _talloc_steal_loc and returns the pointer that you pass it. It does not have any failure modes.
If the output value is ignored there are compiler warnings.
Example of warning src/util/util.c:503:164: warning: expression result unused [-Wunused-value] ({ __typeof__(internal_ctx) __talloc_steal_ret = (__typeof__(internal_ctx))_talloc_steal_loc((table),(internal_ctx), "../sssd/src/util/util.c" ":" "503"); __talloc_steal_ret; }); ^~~~~~~~~~~~~~~~~~ 1 warning generated.
I am opened to better solution of this warning.
LS
I would ignore this warning. Ignoring return value has lots of use cases.
On (12/01/15 13:27), Pavel Březina wrote:
On 01/10/2015 06:12 PM, Lukas Slebodnik wrote:
ehlo,
talloc_steal is a macro around function _talloc_steal_loc and returns the pointer that you pass it. It does not have any failure modes.
If the output value is ignored there are compiler warnings.
Example of warning src/util/util.c:503:164: warning: expression result unused [-Wunused-value] ({ __typeof__(internal_ctx) __talloc_steal_ret = (__typeof__(internal_ctx))_talloc_steal_loc((table),(internal_ctx), "../sssd/src/util/util.c" ":" "503"); __talloc_steal_ret; }); ^~~~~~~~~~~~~~~~~~ 1 warning generated.
I am opened to better solution of this warning.
LS
I would ignore this warning. Ignoring return value has lots of use cases.
Actually it is not ignoring returned value from function (-Wunused-result) because talloc_steal is macro and you are ignoring unused value in expanded macro (-Wunused-value)
It could be reason why Jakub did not noticed warning https://lists.fedorahosted.org/pipermail/sssd-devel/2015-January/022195.html He uses clang as well.
LS
sssd-devel@lists.fedorahosted.org