Print this page
6717509 Need to use bswap/bswapq for byte swap of 64-bit integer on x32/x64 (fix lint)

Split Close
Expand all
Collapse all
          --- old/usr/src/common/crypto/md4/md4.c
          +++ new/usr/src/common/crypto/md4/md4.c
↓ open down ↓ 262 lines elided ↑ open up ↑
 263  263   * Encodes input (uint32_t) into output (unsigned char). Assumes len is
 264  264   * a multiple of 4.
 265  265   */
 266  266  static void
 267  267  Encode(unsigned char *output, uint32_t *input, unsigned int len)
 268  268  {
 269  269          unsigned int i, j;
 270  270  
 271  271          for (i = 0, j = 0; j < len; i++, j += 4) {
 272  272  #if defined(_LITTLE_ENDIAN) && defined(UNALIGNED_POINTERS_PERMITTED)
 273      -                *(uint32_t *)&output[j] = input[i];
      273 +                *(uint32_t *)(void *)&output[j] = input[i];
 274  274  #else
 275  275                  /* endian-independent code */
 276  276                  output[j] = (unsigned char)(input[i] & 0xff);
 277  277                  output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
 278  278                  output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
 279  279                  output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
 280  280  #endif  /* _LITTLE_ENDIAN && UNALIGNED_POINTERS_PERMITTED */
 281  281          }
 282  282  }
 283  283  
↓ open down ↓ 1 lines elided ↑ open up ↑
 285  285   * Decodes input (unsigned char) into output (uint32_t). Assumes len is
 286  286   * a multiple of 4.
 287  287   */
 288  288  static void
 289  289  Decode(uint32_t *output, unsigned char *input, unsigned int len)
 290  290  {
 291  291          unsigned int i, j;
 292  292  
 293  293          for (i = 0, j = 0; j < len; i++, j += 4) {
 294  294  #if defined(_LITTLE_ENDIAN) && defined(UNALIGNED_POINTERS_PERMITTED)
 295      -                output[i] = *(uint32_t *)&input[j];
      295 +                output[i] = *(uint32_t *)(void *)&input[j];
 296  296  #else
 297  297                  /* endian-independent code */
 298  298                  output[i] = ((uint32_t)input[j]) |
 299  299                      (((uint32_t)input[j+1]) << 8) |
 300  300                      (((uint32_t)input[j+2]) << 16) |
 301  301                      (((uint32_t)input[j+3]) << 24);
 302  302  #endif  /* _LITTLE_ENDIAN && UNALIGNED_POINTERS_PERMITTED */
 303  303          }
 304  304  
 305  305  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX