summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2014-11-23 19:56:27 +0200
committerArnold D. Robbins <arnold@skeeve.com>2014-11-23 19:56:27 +0200
commit2513062a4c89b0b60c3717d506fce841d44d871e (patch)
treeae2a21e0a0e0173c1c8b44e9e087da1ab357d66b
parent838f65088cda84edc2df609d3e388acb3c8eb13d (diff)
downloadgawk-2513062a4c89b0b60c3717d506fce841d44d871e.tar.gz
Fix compile problems and warnings on current GCC (4.9.2).
-rw-r--r--ChangeLog5
-rw-r--r--awk.h126
-rw-r--r--extension/ChangeLog5
-rw-r--r--extension/inplace.c8
4 files changed, 79 insertions, 65 deletions
diff --git a/ChangeLog b/ChangeLog
index c24ecd3f..f47aeded 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-11-23 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awk.h: Move all inline functions to the bottom of the file.
+ Keeps modern GCC happier.
+
2014-11-22 Arnold D. Robbins <arnold@skeeve.com>
* awk.h (emalloc, realloc): Redefine in terms of ...
diff --git a/awk.h b/awk.h
index 84c8ca0e..3abad6f8 100644
--- a/awk.h
+++ b/awk.h
@@ -1245,74 +1245,12 @@ DEREF(NODE *r)
#define cant_happen() r_fatal("internal error line %d, file: %s", \
__LINE__, __FILE__)
-#define fatal set_loc(__FILE__, __LINE__), r_fatal
-
-static inline void *
-emalloc_real(size_t count, const char *where, const char *var, const char *file, int line)
-{
- void *ret;
-
- if (count == 0)
- fatal("%s:%d: emalloc called with zero bytes", file, line);
-
- ret = (void *) malloc(count);
- if (ret == NULL)
- fatal(_("%s:%d:%s: %s: can't allocate %ld bytes of memory (%s)"),
- file, line, where, var, (long) count, strerror(errno));
-
- return ret;
-}
-
-static inline void *
-erealloc_real(void *ptr, size_t count, const char *where, const char *var, const char *file, int line)
-{
- void *ret;
-
- if (count == 0)
- fatal("%s:%d: erealloc called with zero bytes", file, line);
-
- ret = (void *) realloc(ptr, count);
- if (ret == NULL)
- fatal(_("%s:%d:%s: %s: can't reallocate %ld bytes of memory (%s)"),
- file, line, where, var, (long) count, strerror(errno));
-
- return ret;
-}
-
#define emalloc(var,ty,x,str) (void) (var = (ty) emalloc_real((size_t)(x), str, #var, __FILE__, __LINE__))
#define erealloc(var,ty,x,str) (void) (var = (ty) erealloc_real((void *) var, (size_t)(x), str, #var, __FILE__, __LINE__))
#define efree(p) free(p)
-static inline NODE *
-force_string(NODE *s)
-{
- if ((s->flags & STRCUR) != 0
- && (s->stfmt == -1 || s->stfmt == CONVFMTidx)
- )
- return s;
- return format_val(CONVFMT, CONVFMTidx, s);
-}
-
-#ifdef GAWKDEBUG
-#define unref r_unref
-#define force_number str2number
-#else /* not GAWKDEBUG */
-
-static inline void
-unref(NODE *r)
-{
- if (r != NULL && --r->valref <= 0)
- r_unref(r);
-}
-
-static inline NODE *
-force_number(NODE *n)
-{
- return (n->flags & NUMCUR) ? n : str2number(n);
-}
-
-#endif /* GAWKDEBUG */
+#define fatal set_loc(__FILE__, __LINE__), r_fatal
extern jmp_buf fatal_tag;
extern bool fatal_tag_valid;
@@ -1800,3 +1738,65 @@ dupnode(NODE *n)
return r_dupnode(n);
}
#endif
+
+static inline NODE *
+force_string(NODE *s)
+{
+ if ((s->flags & STRCUR) != 0
+ && (s->stfmt == -1 || s->stfmt == CONVFMTidx)
+ )
+ return s;
+ return format_val(CONVFMT, CONVFMTidx, s);
+}
+
+#ifdef GAWKDEBUG
+#define unref r_unref
+#define force_number str2number
+#else /* not GAWKDEBUG */
+
+static inline void
+unref(NODE *r)
+{
+ if (r != NULL && --r->valref <= 0)
+ r_unref(r);
+}
+
+static inline NODE *
+force_number(NODE *n)
+{
+ return (n->flags & NUMCUR) ? n : str2number(n);
+}
+
+#endif /* GAWKDEBUG */
+
+static inline void *
+emalloc_real(size_t count, const char *where, const char *var, const char *file, int line)
+{
+ void *ret;
+
+ if (count == 0)
+ fatal("%s:%d: emalloc called with zero bytes", file, line);
+
+ ret = (void *) malloc(count);
+ if (ret == NULL)
+ fatal(_("%s:%d:%s: %s: can't allocate %ld bytes of memory (%s)"),
+ file, line, where, var, (long) count, strerror(errno));
+
+ return ret;
+}
+
+static inline void *
+erealloc_real(void *ptr, size_t count, const char *where, const char *var, const char *file, int line)
+{
+ void *ret;
+
+ if (count == 0)
+ fatal("%s:%d: erealloc called with zero bytes", file, line);
+
+ ret = (void *) realloc(ptr, count);
+ if (ret == NULL)
+ fatal(_("%s:%d:%s: %s: can't reallocate %ld bytes of memory (%s)"),
+ file, line, where, var, (long) count, strerror(errno));
+
+ return ret;
+}
diff --git a/extension/ChangeLog b/extension/ChangeLog
index 940f7f15..41c8a0e4 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,8 @@
+2014-11-23 Arnold D. Robbins <arnold@skeeve.com>
+
+ * inplace.c (do_inplace_begin): Jump through hoops to silence
+ GCC warnings about return value of chown.
+
2014-10-12 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am (uninstall-so): Remove *.lib too, per suggestion
diff --git a/extension/inplace.c b/extension/inplace.c
index 8a7375c4..0693ad92 100644
--- a/extension/inplace.c
+++ b/extension/inplace.c
@@ -170,8 +170,12 @@ do_inplace_begin(int nargs, awk_value_t *result)
state.tname, strerror(errno));
/* N.B. chown/chmod should be more portable than fchown/fchmod */
- if (chown(state.tname, sbuf.st_uid, sbuf.st_gid) < 0)
- (void) chown(state.tname, -1, sbuf.st_gid);
+ if (chown(state.tname, sbuf.st_uid, sbuf.st_gid) < 0) {
+ /* jumping through hoops to silence gcc. :-( */
+ int junk;
+ junk = chown(state.tname, -1, sbuf.st_gid);
+ junk = junk;
+ }
if (chmod(state.tname, sbuf.st_mode) < 0)
fatal(ext_id, _("inplace_begin: chmod failed (%s)"),