fix-warning-bfd.patch 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. From 27b829ee701e29804216b3803fbaeb629be27491 Mon Sep 17 00:00:00 2001
  2. From: Nick Clifton <nickc@redhat.com>
  3. Date: Wed, 29 Jan 2014 13:46:39 +0000
  4. Subject: [PATCH] Following up on Tom's suggestion I am checking in a patch to
  5. replace the various bfd_xxx_set macros with static inline functions, so that
  6. we can avoid compile time warnings about comma expressions with unused
  7. values.
  8. * bfd-in.h (bfd_set_section_vma): Delete.
  9. (bfd_set_section_alignment): Delete.
  10. (bfd_set_section_userdata): Delete.
  11. (bfd_set_cacheable): Delete.
  12. * bfd.c (bfd_set_cacheable): New static inline function.
  13. * section.c (bfd_set_section_userdata): Likewise.
  14. (bfd_set_section_vma): Likewise.
  15. (bfd_set_section_alignment): Likewise.
  16. * bfd-in2.h: Regenerate.
  17. ---
  18. bfd/bfd-in.h | 5 -----
  19. bfd/bfd-in2.h | 41 +++++++++++++++++++++++++++++++++++------
  20. bfd/bfd.c | 8 ++++++++
  21. bfd/section.c | 26 ++++++++++++++++++++++++++
  22. 5 files changed, 81 insertions(+), 11 deletions(-)
  23. diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
  24. index 3afd71b..c7c5a7d 100644
  25. --- a/bfd/bfd-in.h
  26. +++ b/bfd/bfd-in.h
  27. @@ -292,9 +292,6 @@ typedef struct bfd_section *sec_ptr;
  28. #define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
  29. -#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
  30. -#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
  31. -#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
  32. /* Find the address one past the end of SEC. */
  33. #define bfd_get_section_limit(bfd, sec) \
  34. (((bfd)->direction != write_direction && (sec)->rawsize != 0 \
  35. @@ -517,8 +514,6 @@ extern void warn_deprecated (const char *, const char *, int, const char *);
  36. #define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
  37. -#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE)
  38. -
  39. extern bfd_boolean bfd_cache_close
  40. (bfd *abfd);
  41. /* NB: This declaration should match the autogenerated one in libbfd.h. */
  42. diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
  43. index 71996db..b5aeb40 100644
  44. --- a/bfd/bfd-in2.h
  45. +++ b/bfd/bfd-in2.h
  46. @@ -299,9 +299,6 @@ typedef struct bfd_section *sec_ptr;
  47. #define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
  48. -#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
  49. -#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
  50. -#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
  51. /* Find the address one past the end of SEC. */
  52. #define bfd_get_section_limit(bfd, sec) \
  53. (((bfd)->direction != write_direction && (sec)->rawsize != 0 \
  54. @@ -524,8 +521,6 @@ extern void warn_deprecated (const char *, const char *, int, const char *);
  55. #define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
  56. -#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE)
  57. -
  58. extern bfd_boolean bfd_cache_close
  59. (bfd *abfd);
  60. /* NB: This declaration should match the autogenerated one in libbfd.h. */
  61. @@ -1029,7 +1024,7 @@ bfd *bfd_openr (const char *filename, const char *target);
  62. bfd *bfd_fdopenr (const char *filename, const char *target, int fd);
  63. -bfd *bfd_openstreamr (const char *, const char *, void *);
  64. +bfd *bfd_openstreamr (const char * filename, const char * target, void * stream);
  65. bfd *bfd_openr_iovec (const char *filename, const char *target,
  66. void *(*open_func) (struct bfd *nbfd,
  67. @@ -1596,6 +1591,32 @@ struct relax_table {
  68. int size;
  69. };
  70. +/* Note: the following are provided as inline functions rather than macros
  71. + because not all callers use the return value. A macro implementation
  72. + would use a comma expression, eg: "((ptr)->foo = val, TRUE)" and some
  73. + compilers will complain about comma expressions that have no effect. */
  74. +static inline bfd_boolean
  75. +bfd_set_section_userdata (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, void * val)
  76. +{
  77. + ptr->userdata = val;
  78. + return TRUE;
  79. +}
  80. +
  81. +static inline bfd_boolean
  82. +bfd_set_section_vma (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, bfd_vma val)
  83. +{
  84. + ptr->vma = ptr->lma = val;
  85. + ptr->user_set_vma = TRUE;
  86. + return TRUE;
  87. +}
  88. +
  89. +static inline bfd_boolean
  90. +bfd_set_section_alignment (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, unsigned int val)
  91. +{
  92. + ptr->alignment_power = val;
  93. + return TRUE;
  94. +}
  95. +
  96. /* These sections are global, and are managed by BFD. The application
  97. and target back end are not permitted to change the values in
  98. these sections. */
  99. @@ -6415,6 +6436,14 @@ struct bfd
  100. unsigned int selective_search : 1;
  101. };
  102. +/* See note beside bfd_set_section_userdata. */
  103. +static inline bfd_boolean
  104. +bfd_set_cacheable (bfd * abfd, bfd_boolean val)
  105. +{
  106. + abfd->cacheable = val;
  107. + return TRUE;
  108. +}
  109. +
  110. typedef enum bfd_error
  111. {
  112. bfd_error_no_error = 0,
  113. diff --git a/bfd/bfd.c b/bfd/bfd.c
  114. index 8d0580c..2d174f3 100644
  115. --- a/bfd/bfd.c
  116. +++ b/bfd/bfd.c
  117. @@ -311,6 +311,14 @@ CODE_FRAGMENT
  118. . unsigned int selective_search : 1;
  119. .};
  120. .
  121. +.{* See note beside bfd_set_section_userdata. *}
  122. +.static inline bfd_boolean
  123. +.bfd_set_cacheable (bfd * abfd, bfd_boolean val)
  124. +.{
  125. +. abfd->cacheable = val;
  126. +. return TRUE;
  127. +.}
  128. +.
  129. */
  130. #include "sysdep.h"
  131. diff --git a/bfd/section.c b/bfd/section.c
  132. index fb19d8c..a661228 100644
  133. --- a/bfd/section.c
  134. +++ b/bfd/section.c
  135. @@ -542,6 +542,32 @@ CODE_FRAGMENT
  136. . int size;
  137. .};
  138. .
  139. +.{* Note: the following are provided as inline functions rather than macros
  140. +. because not all callers use the return value. A macro implementation
  141. +. would use a comma expression, eg: "((ptr)->foo = val, TRUE)" and some
  142. +. compilers will complain about comma expressions that have no effect. *}
  143. +.static inline bfd_boolean
  144. +.bfd_set_section_userdata (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, void * val)
  145. +.{
  146. +. ptr->userdata = val;
  147. +. return TRUE;
  148. +.}
  149. +.
  150. +.static inline bfd_boolean
  151. +.bfd_set_section_vma (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, bfd_vma val)
  152. +.{
  153. +. ptr->vma = ptr->lma = val;
  154. +. ptr->user_set_vma = TRUE;
  155. +. return TRUE;
  156. +.}
  157. +.
  158. +.static inline bfd_boolean
  159. +.bfd_set_section_alignment (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, unsigned int val)
  160. +.{
  161. +. ptr->alignment_power = val;
  162. +. return TRUE;
  163. +.}
  164. +.
  165. .{* These sections are global, and are managed by BFD. The application
  166. . and target back end are not permitted to change the values in
  167. . these sections. *}
  168. --
  169. 2.1.4