[SSSD] [PATCH 4/7] responder: Use SAFEALIGN macros where appropriate.
Lukas Slebodnik
lslebodn at redhat.com
Thu Nov 28 10:59:07 UTC 2013
On (19/11/13 14:01), Michal Židek wrote:
>On 11/18/2013 04:02 PM, Lukas Slebodnik wrote:
>>Few warnings are not fixed in the file src/responder/nss/nsssrv_cmd.c
>>and patches {0005, 0006} do not change this file.
>>
>> CC src/responder/nss/nsssrv_cmd.o
>>src/responder/nss/nsssrv_cmd.c:1017:6: warning: cast from 'uint8_t *' (aka 'unsigned char *') to
>> 'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Wcast-align]
>> ((uint32_t *)body)[0] = 1; /* num results */
>> ^~~~~~~~~~~~~~~~
>>src/responder/nss/nsssrv_cmd.c:1018:6: warning: cast from 'uint8_t *' (aka 'unsigned char *') to
>> 'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Wcast-align]
>> ((uint32_t *)body)[1] = 0; /* reserved */
>> ^~~~~~~~~~~~~~~~
>>src/responder/nss/nsssrv_cmd.c:1019:6: warning: cast from 'uint8_t *' (aka 'unsigned char *') to
>> 'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Wcast-align]
>> ((uint32_t *)body)[2] = (uint32_t) SSS_ID_TYPE_GID;
>> ^~~~~~~~~~~~~~~~
>>src/responder/nss/nsssrv_cmd.c:4400:6: warning: cast from 'uint8_t *' (aka 'unsigned char *') to
>> 'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Wcast-align]
>> ((uint32_t *)body)[0] = 1; /* num results */
>> ^~~~~~~~~~~~~~~~
>>src/responder/nss/nsssrv_cmd.c:4401:6: warning: cast from 'uint8_t *' (aka 'unsigned char *') to
>> 'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Wcast-align]
>> ((uint32_t *)body)[1] = 0; /* reserved */
>> ^~~~~~~~~~~~~~~~
>>src/responder/nss/nsssrv_cmd.c:4402:6: warning: cast from 'uint8_t *' (aka 'unsigned char *') to
>> 'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Wcast-align]
>> ((uint32_t *)body)[2] = (uint32_t) SSS_ID_TYPE_GID;
>> ^~~~~~~~~~~~~~~~
>>6 warnings generated.
>>
>>LS
>>_______________________________________________
>>sssd-devel mailing list
>>sssd-devel at lists.fedorahosted.org
>>https://lists.fedorahosted.org/mailman/listinfo/sssd-devel
>>
>
>Thanks. For the review. New patch is attached.
>
>Michal
Macros SAFEALIGN_SETMEM_UINT32, SAFEALIGN_COPY_UINT32 are not used with the
same purpose. Once, you used 1st macro to store value into buffer and another
time you used 2nd macro for the same purpose.
>- ((uint32_t *)body)[0] = num; /* num results */
>- ((uint32_t *)body)[1] = 0; /* reserved */
>+ SAFEALIGN_COPY_UINT32(body, &num, NULL); /* num results */
>+ SAFEALIGN_SETMEM_UINT32(body + sizeof(uint32_t), 0, NULL); /* reserved */
You also mixed SAFEALIGN_SETMEM_UINT32 with counter
>+ SAFEALIGN_SETMEM_UINT32(body, 1, &pctr); /* num results */
>+ SAFEALIGN_SETMEM_UINT32(body + pctr, 0, &pctr); /* reserved */
>+ SAFEALIGN_SETMEM_UINT32(body + pctr, SSS_ID_TYPE_GID, &pctr);
and another time without counter.
>+ /* Got some results */
>+ SAFEALIGN_SETMEM_UINT32(body, 1, NULL);
>+ /* Reserved padding */
>+ SAFEALIGN_SETMEM_UINT32(body + sizeof(uint32_t), 0, NULL);
LS
More information about the sssd-devel
mailing list