0001-lib-crc32-prefix-public-functions.patch 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. From b39b4cac29dcc5d060d8e30344f693462502066a Mon Sep 17 00:00:00 2001
  2. From: Gustavo Zacarias <gustavo@zacarias.com.ar>
  3. Date: Mon, 10 Oct 2016 17:42:42 -0300
  4. Subject: [PATCH] lib/crc32: prefix public functions
  5. Make the publicly-visible crc32 library functions prefixed by ul_, such
  6. as crc32() -> ul_crc32().
  7. This is because it clashes with the crc32() function from zlib.
  8. For newer versions of glib (2.50+) zlib and libblkid are required
  9. dependencies and otherwise results in build failure when building
  10. statically.
  11. Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
  12. ---
  13. Status: submitted upstream
  14. disk-utils/fsck.cramfs.c | 12 ++++++------
  15. disk-utils/mkfs.cramfs.c | 6 +++---
  16. include/crc32.h | 4 ++--
  17. lib/crc32.c | 4 ++--
  18. libblkid/src/partitions/gpt.c | 2 +-
  19. libblkid/src/superblocks/nilfs.c | 6 +++---
  20. libfdisk/src/gpt.c | 2 +-
  21. 7 files changed, 18 insertions(+), 18 deletions(-)
  22. diff --git a/disk-utils/fsck.cramfs.c b/disk-utils/fsck.cramfs.c
  23. index 12009f2..f34e79f 100644
  24. --- a/disk-utils/fsck.cramfs.c
  25. +++ b/disk-utils/fsck.cramfs.c
  26. @@ -214,7 +214,7 @@ static void test_crc(int start)
  27. return;
  28. }
  29. - crc = crc32(0L, Z_NULL, 0);
  30. + crc = ul_crc32(0L, Z_NULL, 0);
  31. buf =
  32. mmap(NULL, super.size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
  33. @@ -231,8 +231,8 @@ static void test_crc(int start)
  34. }
  35. if (buf != MAP_FAILED) {
  36. ((struct cramfs_super *)((unsigned char *) buf + start))->fsid.crc =
  37. - crc32(0L, Z_NULL, 0);
  38. - crc = crc32(crc, (unsigned char *) buf + start, super.size - start);
  39. + ul_crc32(0L, Z_NULL, 0);
  40. + crc = ul_crc32(crc, (unsigned char *) buf + start, super.size - start);
  41. munmap(buf, super.size);
  42. } else {
  43. int retval;
  44. @@ -249,15 +249,15 @@ static void test_crc(int start)
  45. break;
  46. if (length == 0)
  47. ((struct cramfs_super *)buf)->fsid.crc =
  48. - crc32(0L, Z_NULL, 0);
  49. + ul_crc32(0L, Z_NULL, 0);
  50. length += retval;
  51. if (length > (super.size - start)) {
  52. - crc = crc32(crc, buf,
  53. + crc = ul_crc32(crc, buf,
  54. retval - (length -
  55. (super.size - start)));
  56. break;
  57. }
  58. - crc = crc32(crc, buf, retval);
  59. + crc = ul_crc32(crc, buf, retval);
  60. }
  61. free(buf);
  62. }
  63. diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c
  64. index 4e6b3ab..55d6871 100644
  65. --- a/disk-utils/mkfs.cramfs.c
  66. +++ b/disk-utils/mkfs.cramfs.c
  67. @@ -406,7 +406,7 @@ static unsigned int write_superblock(struct entry *root, char *base, int size)
  68. super->size = size;
  69. memcpy(super->signature, CRAMFS_SIGNATURE, sizeof(super->signature));
  70. - super->fsid.crc = crc32(0L, Z_NULL, 0);
  71. + super->fsid.crc = ul_crc32(0L, Z_NULL, 0);
  72. super->fsid.edition = opt_edition;
  73. super->fsid.blocks = total_blocks;
  74. super->fsid.files = total_nodes;
  75. @@ -700,7 +700,7 @@ int main(int argc, char **argv)
  76. loff_t fslen_ub = sizeof(struct cramfs_super);
  77. unsigned int fslen_max;
  78. char const *dirname, *outfile;
  79. - uint32_t crc = crc32(0L, Z_NULL, 0);
  80. + uint32_t crc = ul_crc32(0L, Z_NULL, 0);
  81. int c;
  82. cramfs_is_big_endian = HOST_IS_BIG_ENDIAN; /* default is to use host order */
  83. @@ -856,7 +856,7 @@ int main(int argc, char **argv)
  84. sizeof(struct cramfs_super));
  85. /* Put the checksum in. */
  86. - crc = crc32(crc, (unsigned char *) (rom_image+opt_pad), (offset-opt_pad));
  87. + crc = ul_crc32(crc, (unsigned char *) (rom_image+opt_pad), (offset-opt_pad));
  88. ((struct cramfs_super *) (rom_image+opt_pad))->fsid.crc = u32_toggle_endianness(cramfs_is_big_endian, crc);
  89. if (verbose)
  90. printf(_("CRC: %x\n"), crc);
  91. diff --git a/include/crc32.h b/include/crc32.h
  92. index ff2dd99..2551f50 100644
  93. --- a/include/crc32.h
  94. +++ b/include/crc32.h
  95. @@ -4,8 +4,8 @@
  96. #include <sys/types.h>
  97. #include <stdint.h>
  98. -extern uint32_t crc32(uint32_t seed, const unsigned char *buf, size_t len);
  99. -extern uint32_t crc32_exclude_offset(uint32_t seed, const unsigned char *buf, size_t len,
  100. +extern uint32_t ul_crc32(uint32_t seed, const unsigned char *buf, size_t len);
  101. +extern uint32_t ul_crc32_exclude_offset(uint32_t seed, const unsigned char *buf, size_t len,
  102. size_t exclude_off, size_t exclude_len);
  103. #endif
  104. diff --git a/lib/crc32.c b/lib/crc32.c
  105. index a5e3216..824693d 100644
  106. --- a/lib/crc32.c
  107. +++ b/lib/crc32.c
  108. @@ -108,7 +108,7 @@ static inline uint32_t crc32_add_char(uint32_t crc, unsigned char c)
  109. * and does __not__ xor at the end. Then individual users can do
  110. * whatever they need.
  111. */
  112. -uint32_t crc32(uint32_t seed, const unsigned char *buf, size_t len)
  113. +uint32_t ul_crc32(uint32_t seed, const unsigned char *buf, size_t len)
  114. {
  115. uint32_t crc = seed;
  116. const unsigned char *p = buf;
  117. @@ -121,7 +121,7 @@ uint32_t crc32(uint32_t seed, const unsigned char *buf, size_t len)
  118. return crc;
  119. }
  120. -uint32_t crc32_exclude_offset(uint32_t seed, const unsigned char *buf, size_t len,
  121. +uint32_t ul_crc32_exclude_offset(uint32_t seed, const unsigned char *buf, size_t len,
  122. size_t exclude_off, size_t exclude_len)
  123. {
  124. uint32_t crc = seed;
  125. diff --git a/libblkid/src/partitions/gpt.c b/libblkid/src/partitions/gpt.c
  126. index dcc04e6..e6baa59 100644
  127. --- a/libblkid/src/partitions/gpt.c
  128. +++ b/libblkid/src/partitions/gpt.c
  129. @@ -105,7 +105,7 @@ struct gpt_entry {
  130. static inline uint32_t count_crc32(const unsigned char *buf, size_t len,
  131. size_t exclude_off, size_t exclude_len)
  132. {
  133. - return (crc32_exclude_offset(~0L, buf, len, exclude_off, exclude_len) ^ ~0L);
  134. + return (ul_crc32_exclude_offset(~0L, buf, len, exclude_off, exclude_len) ^ ~0L);
  135. }
  136. static inline unsigned char *get_lba_buffer(blkid_probe pr,
  137. diff --git a/libblkid/src/superblocks/nilfs.c b/libblkid/src/superblocks/nilfs.c
  138. index ee5c5f9..95538ef 100644
  139. --- a/libblkid/src/superblocks/nilfs.c
  140. +++ b/libblkid/src/superblocks/nilfs.c
  141. @@ -89,9 +89,9 @@ static int nilfs_valid_sb(blkid_probe pr, struct nilfs_super_block *sb, int is_b
  142. if (bytes < crc_start || bytes > sizeof(struct nilfs_super_block))
  143. return 0;
  144. - crc = crc32(le32_to_cpu(sb->s_crc_seed), (unsigned char *)sb, sumoff);
  145. - crc = crc32(crc, sum, 4);
  146. - crc = crc32(crc, (unsigned char *)sb + crc_start, bytes - crc_start);
  147. + crc = ul_crc32(le32_to_cpu(sb->s_crc_seed), (unsigned char *)sb, sumoff);
  148. + crc = ul_crc32(crc, sum, 4);
  149. + crc = ul_crc32(crc, (unsigned char *)sb + crc_start, bytes - crc_start);
  150. return blkid_probe_verify_csum(pr, crc, le32_to_cpu(sb->s_sum));
  151. }
  152. diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c
  153. index 8377192..208699b 100644
  154. --- a/libfdisk/src/gpt.c
  155. +++ b/libfdisk/src/gpt.c
  156. @@ -850,7 +850,7 @@ fail:
  157. static inline uint32_t count_crc32(const unsigned char *buf, size_t len,
  158. size_t ex_off, size_t ex_len)
  159. {
  160. - return (crc32_exclude_offset(~0L, buf, len, ex_off, ex_len) ^ ~0L);
  161. + return (ul_crc32_exclude_offset(~0L, buf, len, ex_off, ex_len) ^ ~0L);
  162. }
  163. static inline uint32_t gpt_header_count_crc32(struct gpt_header *header)
  164. --
  165. 2.7.3