0d13b07
commit 27b829ee701e29804216b3803fbaeb629be27491
0d13b07
Author: Nick Clifton <nickc@redhat.com>
0d13b07
Date:   Wed Jan 29 13:46:39 2014 +0000
0d13b07
0d13b07
    Following up on Tom's suggestion I am checking in a patch to replace the various
0d13b07
    bfd_xxx_set macros with static inline functions, so that we can avoid compile time
0d13b07
    warnings about comma expressions with unused values.
0d13b07
    
0d13b07
    	* bfd-in.h (bfd_set_section_vma): Delete.
0d13b07
    	(bfd_set_section_alignment): Delete.
0d13b07
    	(bfd_set_section_userdata): Delete.
0d13b07
    	(bfd_set_cacheable): Delete.
0d13b07
    	* bfd.c (bfd_set_cacheable): New static inline function.
0d13b07
    	* section.c (bfd_set_section_userdata): Likewise.
0d13b07
    	(bfd_set_section_vma): Likewise.
0d13b07
    	(bfd_set_section_alignment): Likewise.
0d13b07
    	* bfd-in2.h: Regenerate.
0d13b07
0d13b07
diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
0d13b07
index 3afd71b..c7c5a7d 100644
0d13b07
--- a/bfd/bfd-in.h
0d13b07
+++ b/bfd/bfd-in.h
0d13b07
@@ -292,9 +292,6 @@ typedef struct bfd_section *sec_ptr;
0d13b07
 
0d13b07
 #define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
0d13b07
 
0d13b07
-#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
0d13b07
-#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
0d13b07
-#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
0d13b07
 /* Find the address one past the end of SEC.  */
0d13b07
 #define bfd_get_section_limit(bfd, sec) \
0d13b07
   (((bfd)->direction != write_direction && (sec)->rawsize != 0	\
0d13b07
@@ -517,8 +514,6 @@ extern void warn_deprecated (const char *, const char *, int, const char *);
0d13b07
 
0d13b07
 #define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
0d13b07
 
0d13b07
-#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE)
0d13b07
-
0d13b07
 extern bfd_boolean bfd_cache_close
0d13b07
   (bfd *abfd);
0d13b07
 /* NB: This declaration should match the autogenerated one in libbfd.h.  */
0d13b07
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
0d13b07
index 71996db..b5aeb40 100644
0d13b07
--- a/bfd/bfd-in2.h
0d13b07
+++ b/bfd/bfd-in2.h
0d13b07
@@ -299,9 +299,6 @@ typedef struct bfd_section *sec_ptr;
0d13b07
 
0d13b07
 #define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
0d13b07
 
0d13b07
-#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
0d13b07
-#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
0d13b07
-#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
0d13b07
 /* Find the address one past the end of SEC.  */
0d13b07
 #define bfd_get_section_limit(bfd, sec) \
0d13b07
   (((bfd)->direction != write_direction && (sec)->rawsize != 0	\
0d13b07
@@ -524,8 +521,6 @@ extern void warn_deprecated (const char *, const char *, int, const char *);
0d13b07
 
0d13b07
 #define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
0d13b07
 
0d13b07
-#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE)
0d13b07
-
0d13b07
 extern bfd_boolean bfd_cache_close
0d13b07
   (bfd *abfd);
0d13b07
 /* NB: This declaration should match the autogenerated one in libbfd.h.  */
0d13b07
@@ -1029,7 +1024,7 @@ bfd *bfd_openr (const char *filename, const char *target);
0d13b07
 
0d13b07
 bfd *bfd_fdopenr (const char *filename, const char *target, int fd);
0d13b07
 
0d13b07
-bfd *bfd_openstreamr (const char *, const char *, void *);
0d13b07
+bfd *bfd_openstreamr (const char * filename, const char * target, void * stream);
0d13b07
 
0d13b07
 bfd *bfd_openr_iovec (const char *filename, const char *target,
0d13b07
     void *(*open_func) (struct bfd *nbfd,
0d13b07
@@ -1596,6 +1591,32 @@ struct relax_table {
0d13b07
   int size;
0d13b07
 };
0d13b07
 
0d13b07
+/* Note: the following are provided as inline functions rather than macros
0d13b07
+   because not all callers use the return value.  A macro implementation
0d13b07
+   would use a comma expression, eg: "((ptr)->foo = val, TRUE)" and some
0d13b07
+   compilers will complain about comma expressions that have no effect.  */
0d13b07
+static inline bfd_boolean
0d13b07
+bfd_set_section_userdata (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, void * val)
0d13b07
+{
0d13b07
+  ptr->userdata = val;
0d13b07
+  return TRUE;
0d13b07
+}
0d13b07
+
0d13b07
+static inline bfd_boolean
0d13b07
+bfd_set_section_vma (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, bfd_vma val)
0d13b07
+{
0d13b07
+  ptr->vma = ptr->lma = val;
0d13b07
+  ptr->user_set_vma = TRUE;
0d13b07
+  return TRUE;
0d13b07
+}
0d13b07
+
0d13b07
+static inline bfd_boolean
0d13b07
+bfd_set_section_alignment (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, unsigned int val)
0d13b07
+{
0d13b07
+  ptr->alignment_power = val;
0d13b07
+  return TRUE;
0d13b07
+}
0d13b07
+
0d13b07
 /* These sections are global, and are managed by BFD.  The application
0d13b07
    and target back end are not permitted to change the values in
0d13b07
    these sections.  */
0d13b07
@@ -6415,6 +6436,14 @@ struct bfd
0d13b07
   unsigned int selective_search : 1;
0d13b07
 };
0d13b07
 
0d13b07
+/* See note beside bfd_set_section_userdata.  */
0d13b07
+static inline bfd_boolean
0d13b07
+bfd_set_cacheable (bfd * abfd, bfd_boolean val)
0d13b07
+{
0d13b07
+  abfd->cacheable = val;
0d13b07
+  return TRUE;
0d13b07
+}
0d13b07
+
0d13b07
 typedef enum bfd_error
0d13b07
 {
0d13b07
   bfd_error_no_error = 0,
0d13b07
diff --git a/bfd/bfd.c b/bfd/bfd.c
0d13b07
index 8d0580c..2d174f3 100644
0d13b07
--- a/bfd/bfd.c
0d13b07
+++ b/bfd/bfd.c
0d13b07
@@ -311,6 +311,14 @@ CODE_FRAGMENT
0d13b07
 .  unsigned int selective_search : 1;
0d13b07
 .};
0d13b07
 .
0d13b07
+.{* See note beside bfd_set_section_userdata.  *}
0d13b07
+.static inline bfd_boolean
0d13b07
+.bfd_set_cacheable (bfd * abfd, bfd_boolean val)
0d13b07
+.{
0d13b07
+.  abfd->cacheable = val;
0d13b07
+.  return TRUE;
0d13b07
+.}
0d13b07
+.
0d13b07
 */
0d13b07
 
0d13b07
 #include "sysdep.h"
0d13b07
diff --git a/bfd/section.c b/bfd/section.c
0d13b07
index fb19d8c..a661228 100644
0d13b07
--- a/bfd/section.c
0d13b07
+++ b/bfd/section.c
0d13b07
@@ -542,6 +542,32 @@ CODE_FRAGMENT
0d13b07
 .  int size;
0d13b07
 .};
0d13b07
 .
0d13b07
+.{* Note: the following are provided as inline functions rather than macros
0d13b07
+.   because not all callers use the return value.  A macro implementation
0d13b07
+.   would use a comma expression, eg: "((ptr)->foo = val, TRUE)" and some
0d13b07
+.   compilers will complain about comma expressions that have no effect.  *}
0d13b07
+.static inline bfd_boolean
0d13b07
+.bfd_set_section_userdata (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, void * val)
0d13b07
+.{
0d13b07
+.  ptr->userdata = val;
0d13b07
+.  return TRUE;
0d13b07
+.}
0d13b07
+.
0d13b07
+.static inline bfd_boolean
0d13b07
+.bfd_set_section_vma (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, bfd_vma val)
0d13b07
+.{
0d13b07
+.  ptr->vma = ptr->lma = val;
0d13b07
+.  ptr->user_set_vma = TRUE;
0d13b07
+.  return TRUE;
0d13b07
+.}
0d13b07
+.
0d13b07
+.static inline bfd_boolean
0d13b07
+.bfd_set_section_alignment (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, unsigned int val)
0d13b07
+.{
0d13b07
+.  ptr->alignment_power = val;
0d13b07
+.  return TRUE;
0d13b07
+.}
0d13b07
+.
0d13b07
 .{* These sections are global, and are managed by BFD.  The application
0d13b07
 .   and target back end are not permitted to change the values in
0d13b07
 .   these sections.  *}