Not building on i386

From: Eugene <eval_at_veng.tk>
Date: Wed, 22 Mar 2023 06:49:31 UTC
Hello

When trying to build www/apache24 on the i386 platform, an error occurs while building the http2 module:

h2_util.c:1183:23: error: result of comparison of constant 9223372036854775807 with expression of type 'apr_size_t' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
         && b->length > APR_INT64_MAX)
            ~~~~~~~~~ ^ ~~~~~~~~~~~~~
1 error generated.
*** Error code 1

Stop.
make[6]: stopped in /usr/obj/ports/usr/ports/www/apache24/work/httpd-2.4.56/modules/http2
*** Error code 1

Stop.
make[5]: stopped in /usr/obj/ports/usr/ports/www/apache24/work/httpd-2.4.56/modules/http2
*** Error code 1

Stop.
make[4]: stopped in /usr/obj/ports/usr/ports/www/apache24/work/httpd-2.4.56/modules
*** Error code 1

Stop.
make[3]: stopped in /usr/obj/ports/usr/ports/www/apache24/work/httpd-2.4.56
*** Error code 1

Stop.
make[2]: stopped in /usr/obj/ports/usr/ports/www/apache24/work/httpd-2.4.56
*** Error code 1



As a result, Apache cannot be built on a 32-bit system. A patch is required to resolve this issue.


-------------------------------
The original function where the error occurs

/*******************************************************************************
 * h2_util for bucket brigades
 ******************************************************************************/

static void fit_bucket_into(apr_bucket *b, apr_off_t *plen)
{
    /* signed apr_off_t is at least as large as unsigned apr_size_t.
     * Problems may arise when they are both the same size. Then
     * the bucket length *may* be larger than a value we can hold
     * in apr_off_t. Before casting b->length to apr_off_t we must
     * check the limitations.
     * After we resized the bucket, it is safe to cast and substract.
     */
    if ((sizeof(apr_off_t) == sizeof(apr_int64_t)
         && b->length > APR_INT64_MAX)
       || (sizeof(apr_off_t) == sizeof(apr_int32_t)
           && b->length > APR_INT32_MAX)
       || *plen < (apr_off_t)b->length) {
        /* bucket is longer the *plen */
        apr_bucket_split(b, *plen);
    }
    *plen -= (apr_off_t)b->length;
}
--------------------------------

I do so in order to somehow compile Apache

static void fit_bucket_into(apr_bucket *b, apr_off_t *plen)
{
    /* signed apr_off_t is at least as large as unsigned apr_size_t.
     * Problems may arise when they are both the same size. Then
     * the bucket length *may* be larger than a value we can hold
     * in apr_off_t. Before casting b->length to apr_off_t we must
     * check the limitations.
     * After we resized the bucket, it is safe to cast and substract.
     */
    if ((sizeof(apr_off_t) == sizeof(apr_int32_t)
           && b->length > APR_INT32_MAX)
       || *plen < (apr_off_t)b->length) {
        /* bucket is longer the *plen */
        apr_bucket_split(b, *plen);
    }
    *plen -= (apr_off_t)b->length;
}


But as intended, this is not entirely correct. We need a beautiful and correct solution to correct the situation


-- 
Eugene <eval@veng.tk>