You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Ruediger Pluem <rp...@apache.org> on 2011/01/18 19:12:28 UTC
Re: svn commit: r1060104 - /apr/apr/trunk/strings/apr_snprintf.c
On 01/17/2011 10:37 PM, jim@apache.org wrote:
> Author: jim
> Date: Mon Jan 17 21:37:58 2011
> New Revision: 1060104
>
> URL: http://svn.apache.org/viewvc?rev=1060104&view=rev
> Log:
> Fix cases where off_t (and APR_OFF_T_FMT) may be "larger" than
> int64 (and APR_INT64_T_FMT).
>
> Modified:
> apr/apr/trunk/strings/apr_snprintf.c
>
> Modified: apr/apr/trunk/strings/apr_snprintf.c
> URL: http://svn.apache.org/viewvc/apr/apr/trunk/strings/apr_snprintf.c?rev=1060104&r1=1060103&r2=1060104&view=diff
> ==============================================================================
> --- apr/apr/trunk/strings/apr_snprintf.c (original)
> +++ apr/apr/trunk/strings/apr_snprintf.c Mon Jan 17 21:37:58 2011
> @@ -810,10 +810,27 @@ APR_DECLARE(int) apr_vformatter(int (*fl
> adjust_precision = adjust_width = NO;
>
> /*
> - * Modifier check. Note that if APR_INT64_T_FMT is "d",
> - * the first if condition is never true.
> + * Modifier check. In same cases, APR_OFF_T_FMT can be
> + * "lld" and APR_INT64_T_FMT can be "ld" (that is, off_t is
> + * "larger" than int64). Check that case 1st.
> + * Note that if APR_OFF_T_FMT is "d",
> + * the first if condition is never true. If APR_INT64_T_FMT
> + * is "d' then the second if condition is never true.
> */
> - if ((sizeof(APR_INT64_T_FMT) == 4 &&
> + if ((sizeof(APR_OFF_T_FMT) > sizeof(APR_INT64_T_FMT)) &&
> + (sizeof(APR_OFF_T_FMT) == 4 &&
> + fmt[0] == APR_OFF_T_FMT[0] &&
> + fmt[1] == APR_OFF_T_FMT[1]) ||
> + (sizeof(APR_OFF_T_FMT) == 3 &&
> + fmt[0] == APR_OFF_T_FMT[0]) ||
> + (sizeof(APR_OFF_T_FMT) > 4 &&
> + strncmp(fmt, APR_OFF_T_FMT,
> + sizeof(APR_OFF_T_FMT) - 2) == 0)) {
> + /* Need to account for trailing 'd' and null in sizeof() */
> + var_type = IS_QUAD;
> + fmt += (sizeof(APR_OFF_T_FMT) - 2);
> + }
> + else if ((sizeof(APR_INT64_T_FMT) == 4 &&
This gives me the following warning:
strings/apr_snprintf.c: In function 'apr_vformatter':
strings/apr_snprintf.c:825: warning: suggest parentheses around && within ||
Regards
RĂ¼diger