On Tue, May 04, 2021 at 09:12:04AM +0200, jean-frederic clere wrote:
> On 04/05/2021 08:59, jean-frederic clere wrote:
...
> > In file included from htcacheclean.c:36:
> > htcacheclean.c: In function ‘process_dir’:
> > /home/jfclere/APR-1.7.x/include/apr-1/apr_ring.h:183:37: error: array
> > subscript ‘struct _direntry[0]’ is partly outside array bounds of
> > ‘struct <anonymous>[1]’ [-Werror=array-bounds]
> > 183 | #define APR_RING_PREV(ep, link) (ep)->link.prev
> > | ^~
> > /home/jfclere/APR-1.7.x/include/apr-1/apr_ring.h:230:38: note: in
> > expansion of macro ‘APR_RING_PREV’
> > 230 | APR_RING_PREV((ep1), link) = APR_RING_PREV((lep),
> > link); \
> > |
> > +++
> >
> > Before looking more closely to the problem I have a question, trunk
> > should be building with apr 1.7.x and apr-util 1.6.x correct?
> >
> > I used to build with apr 1.6.x and apr-util 1.6.x but something looks
> > broken now.
>
> Or is that a regression in gcc on fedora34? :-(
It seems to be new with GCC 11, these are warnings which become errors
you since are using --enable-maintainer-mode.
The extensive use of APR_RING* is warning-free in all the APR bucket
brigade code even with GCC 11, it is the different way the ring API is
used in both htcacheclean and event/simple which which is triggering
warnings here.
In both case we have an APR_RING_ENTRY declared outside of the structure
which they are embedded in. Perhaps this is one of the implications
warned about in apr_ring.h:
https://svn.apache.org/viewvc/apr/apr/trunk/include/apr_ring.h?revision=1074876&view=markup#l65
It seems trivial to fix the warning by using the link as embedded in the
structure (attached), though I haven't tested this.
Regards, Joe
Index: support/htcacheclean.c
===================================================================
--- support/htcacheclean.c (revision 1889605)
+++ support/htcacheclean.c (working copy)
@@ -110,7 +110,7 @@
static apr_file_t *outfile; /* stdout file handle */
static apr_off_t unsolicited; /* file size summary for deleted unsolicited
files */
-static APR_RING_ENTRY(_entry) root; /* ENTRY ring anchor */
+static ENTRY root; /* ENTRY ring anchor */
/* short program name as called */
static const char *shortname = "htcacheclean";
@@ -605,13 +605,12 @@
apr_size_t len;
apr_time_t current, deviation;
char *nextpath, *base, *ext;
- APR_RING_ENTRY(_direntry) anchor;
- DIRENTRY *d, *t, *n;
+ DIRENTRY *d, *t, *n, anchor;
ENTRY *e;
int skip, retries;
disk_cache_info_t disk_info;
- APR_RING_INIT(&anchor, _direntry, link);
+ APR_RING_INIT(&anchor.link, _direntry, link);
apr_pool_create(&p, pool);
h = apr_hash_make(p);
fd = NULL;
@@ -627,7 +626,7 @@
}
d = apr_pcalloc(p, sizeof(DIRENTRY));
d->basename = apr_pstrcat(p, path, "/", info.name, NULL);
- APR_RING_INSERT_TAIL(&anchor, d, _direntry, link);
+ APR_RING_INSERT_TAIL(&anchor.link, d, _direntry, link);
(*nodes)++;
}
@@ -639,8 +638,8 @@
skip = baselen + 1;
- for (d = APR_RING_FIRST(&anchor);
- !interrupted && d != APR_RING_SENTINEL(&anchor, _direntry, link);
+ for (d = APR_RING_FIRST(&anchor.link);
+ !interrupted && d != APR_RING_SENTINEL(&anchor.link, _direntry, link);
d=n) {
n = APR_RING_NEXT(d, link);
base = strrchr(d->basename, '/');
@@ -785,7 +784,7 @@
&len) == APR_SUCCESS) {
apr_file_close(fd);
e = apr_palloc(pool, sizeof(ENTRY));
- APR_RING_INSERT_TAIL(&root, e, _entry, link);
+ APR_RING_INSERT_TAIL(&root.link, e, _entry, link);
e->expire = disk_info.expire;
e->response_time = disk_info.response_time;
e->htime = d->htime;
@@ -901,7 +900,7 @@
&len) == APR_SUCCESS) {
apr_file_close(fd);
e = apr_palloc(pool, sizeof(ENTRY));
- APR_RING_INSERT_TAIL(&root, e, _entry, link);
+ APR_RING_INSERT_TAIL(&root.link, e, _entry, link);
e->expire = disk_info.expire;
e->response_time = disk_info.response_time;
e->htime = d->htime;
@@ -988,8 +987,8 @@
s.inodes = inodes;
s.ntotal = nodes;
- for (e = APR_RING_FIRST(&root);
- e != APR_RING_SENTINEL(&root, _entry, link);
+ for (e = APR_RING_FIRST(&root.link);
+ e != APR_RING_SENTINEL(&root.link, _entry, link);
e = APR_RING_NEXT(e, link)) {
s.sum += round_up((apr_size_t)e->hsize, round);
s.sum += round_up((apr_size_t)e->dsize, round);
@@ -1008,8 +1007,8 @@
* happen if a wrong system time is corrected
*/
- for (e = APR_RING_FIRST(&root);
- e != APR_RING_SENTINEL(&root, _entry, link) && !interrupted;) {
+ for (e = APR_RING_FIRST(&root.link);
+ e != APR_RING_SENTINEL(&root.link, _entry, link) && !interrupted;) {
n = APR_RING_NEXT(e, link);
if (e->response_time > now || e->htime > now || e->dtime > now) {
delete_entry(path, e->basename, &s.nodes, pool);
@@ -1033,8 +1032,8 @@
}
/* process all entries which are expired */
- for (e = APR_RING_FIRST(&root);
- e != APR_RING_SENTINEL(&root, _entry, link) && !interrupted;) {
+ for (e = APR_RING_FIRST(&root.link);
+ e != APR_RING_SENTINEL(&root.link, _entry, link) && !interrupted;) {
n = APR_RING_NEXT(e, link);
if (e->expire != APR_DATE_BAD && e->expire < now) {
delete_entry(path, e->basename, &s.nodes, pool);
@@ -1063,11 +1062,11 @@
* than sorry
*/
while (!((!s.max || s.sum <= s.max) && (!s.inodes || s.nodes <= s.inodes))
- && !interrupted && !APR_RING_EMPTY(&root, _entry, link)) {
- oldest = APR_RING_FIRST(&root);
+ && !interrupted && !APR_RING_EMPTY(&root.link, _entry, link)) {
+ oldest = APR_RING_FIRST(&root.link);
for (e = APR_RING_NEXT(oldest, link);
- e != APR_RING_SENTINEL(&root, _entry, link);
+ e != APR_RING_SENTINEL(&root.link, _entry, link);
e = APR_RING_NEXT(e, link)) {
if (e->dtime < oldest->dtime) {
oldest = e;
@@ -1718,7 +1717,7 @@
apr_pool_create(&instance, pool);
now = apr_time_now();
- APR_RING_INIT(&root, _entry, link);
+ APR_RING_INIT(&root.link, _entry, link);
delcount = 0;
unsolicited = 0;
dowork = 0;