• H
    lib: uuid: alignment error in gen_rand_uuid() · a1b633df
    Heinrich Schuchardt 提交于
    Packed structures like struct uuid are not aligned. GCC 9.1 therefore
    throws an error when trying to compile gen_rand_uuid().
    
    lib/uuid.c: In function ‘gen_rand_uuid’:
    lib/uuid.c:244:2: error: converting a packed ‘struct uuid’ pointer
    (alignment 1) to a ‘unsigned int’ pointer (alignment 4) may result in
    an unaligned pointer value [-Werror=address-of-packed-member]
      244 |  unsigned int *ptr = (unsigned int *)&uuid;
          |  ^~~~~~~~
    
    Generate the uuid in a properly aligned buffer.
    
    The byte order of a random number should not matter. Do not call
    cpu_to_be32() to change the byte order.
    Reported-by: NRamon Fried <rfried.dev@gmail.com>
    Signed-off-by: NHeinrich Schuchardt <xypron.glpk@gmx.de>
    a1b633df
uuid.c 8.3 KB