Changeset 27947 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Nov 21, 2007, 7:08:41 PM (18 years ago)
Author:
[email protected]
Message:

Fix <rdar://problem/5602936> Need to resolve new GCC 4.2 warnings.

Reviewed by Tim Hatcher.

Fix all warnings emitted by GCC 4.2 when building JavaScriptCore. This allows builds with
-Werror to succeed. At present they will crash when executed due to code that is not safe
under strict aliasing (<rdar://problem/5536806>).

This required some format strings to be modified in WebCore and WebKit as their format
specifiers did not match the argument type.

Location:
trunk/JavaScriptCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r27913 r27947  
     12007-11-20  Mark Rowe  <[email protected]>
     2
     3        Reviewed by Tim Hatcher.
     4
     5        <rdar://problem/5602936> Need to resolve new GCC 4.2 warnings
     6
     7        Fix all warnings emitted by GCC 4.2 when building JavaScriptCore.  This allows builds with
     8        -Werror to succeed.  At present they will crash when executed due to code that is not safe
     9        under strict aliasing (<rdar://problem/5536806>).
     10
     11        * Configurations/Base.xcconfig: Exclude the -Wno-long-double flag when building with GCC 4.2.
     12        * kjs/date_object.cpp:
     13        (KJS::formatTime): Test whether the stack-allocated string is empty rather than at a non-null address.
     14        * kjs/dtoa.cpp:
     15        (Bigint::): Tweak formatting to silence warnings.
     16        * pcre/pcre_exec.cpp:
     17        (match): Tweak formatting to silence warnings
     18        * wtf/Assertions.cpp: Add printf format attribute to functions that warrant it.
     19        * wtf/Assertions.h: Ditto.
     20
    1212007-11-19  Kevin Ollivier  <[email protected]>
    222
  • trunk/JavaScriptCore/Configurations/Base.xcconfig

    r27845 r27947  
    2424VALID_ARCHS = i386 ppc x86_64 ppc64;
    2525WARNING_CFLAGS = $(WARNING_CFLAGS_$(CURRENT_ARCH));
    26 WARNING_CFLAGS_BASE = -Wall -W -Wcast-align -Wchar-subscripts -Wformat-security -Wmissing-format-attribute -Wpointer-arith -Wwrite-strings -Wno-format-y2k -Wno-long-double -Wundef;
     26WARNING_CFLAGS_BASE = -Wall -W -Wcast-align -Wchar-subscripts -Wformat-security -Wmissing-format-attribute -Wpointer-arith -Wwrite-strings -Wno-format-y2k -Wundef;
    2727WARNING_CFLAGS_ = $(WARNING_CFLAGS_BASE) -Wshorten-64-to-32;
    2828WARNING_CFLAGS_i386 = $(WARNING_CFLAGS_BASE) -Wshorten-64-to-32;
  • trunk/JavaScriptCore/kjs/date_object.cpp

    r27610 r27947  
    230230        strftime(tzname, sizeof(tzname), "%Z", &gtm);
    231231
    232         if (tzname) {
     232        if (tzname[0]) {
    233233            snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d GMT%c%02d%02d (%s)",
    234234                t.hour, t.minute, t.second,
  • trunk/JavaScriptCore/kjs/dtoa.cpp

    r23955 r27947  
    29752975                                                goto bump_up;
    29762976                                        else if (dval(d) < 0.5 - dval(eps)) {
    2977                                                 while(*--s == '0');
     2977                                                while (*--s == '0') { }
    29782978                                                s++;
    29792979                                                goto ret1;
     
    32943294trimzeros:
    32953295#endif
    3296                 while(*--s == '0');
     3296                while (*--s == '0') { }
    32973297                s++;
    32983298                }
  • trunk/JavaScriptCore/pcre/pcre_exec.cpp

    r27847 r27947  
    16581658                                    (*stack.currentFrame->eptr < 128 && (md->ctypes[*stack.currentFrame->eptr] & ctype_space) != 0))
    16591659                                    RRETURN_NO_MATCH;
    1660                                 while (++stack.currentFrame->eptr < md->end_subject && ISMIDCHAR(*stack.currentFrame->eptr));
     1660                                while (++stack.currentFrame->eptr < md->end_subject && ISMIDCHAR(*stack.currentFrame->eptr)) { }
    16611661                            }
    16621662                            break;
     
    16761676                                    (*stack.currentFrame->eptr < 128 && (md->ctypes[*stack.currentFrame->eptr] & ctype_word) != 0))
    16771677                                    RRETURN_NO_MATCH;
    1678                                 while (++stack.currentFrame->eptr < md->end_subject && ISMIDCHAR(*stack.currentFrame->eptr));
     1678                                while (++stack.currentFrame->eptr < md->end_subject && ISMIDCHAR(*stack.currentFrame->eptr)) { }
    16791679                            }
    16801680                            break;
  • trunk/JavaScriptCore/wtf/Assertions.cpp

    r26589 r27947  
    4949extern "C" {
    5050
    51 // This is to work around the "you should use a printf format attribute" warning on GCC
    52 // We can't use _attribute__ ((format (printf, 2, 3))) since we allow %@
    53 static int (* vfprintf_no_warning)(FILE *, const char*, va_list) = vfprintf;
    54 
     51WTF_ATTRIBUTE_PRINTF(1, 0)
    5552static void vprintf_stderr_common(const char* format, va_list args)
    5653{
     
    9289    }
    9390#endif
    94         vfprintf_no_warning(stderr, format, args);
     91    vfprintf(stderr, format, args);
    9592}
    9693
     94WTF_ATTRIBUTE_PRINTF(1, 2)
    9795static void printf_stderr_common(const char* format, ...)
    9896{
  • trunk/JavaScriptCore/wtf/Assertions.h

    r26589 r27947  
    8484#endif
    8585
     86// WTF logging functions can process %@ in the format string to log a NSObject* but the printf format attribute
     87// emits a warning when %@ is used in the format string.  Until <rdar://problem/5195437> is resolved we can't include
     88// the attribute when being used from Objective-C code in case it decides to use %@.
     89#if COMPILER(GCC) && !defined(__OBJC__)
     90#define WTF_ATTRIBUTE_PRINTF(formatStringArgument, extraArguments) __attribute__((__format__(printf, formatStringArgument, extraArguments)))
     91#else
     92#define WTF_ATTRIBUTE_PRINTF(formatStringArgument, extraArguments)
     93#endif
     94
    8695/* These helper functions are always declared, but not necessarily always defined if the corresponding function is disabled. */
    8796
     
    99108
    100109void WTFReportAssertionFailure(const char* file, int line, const char* function, const char* assertion);
    101 void WTFReportAssertionFailureWithMessage(const char* file, int line, const char* function, const char* assertion, const char* format, ...);
     110void WTFReportAssertionFailureWithMessage(const char* file, int line, const char* function, const char* assertion, const char* format, ...) WTF_ATTRIBUTE_PRINTF(5, 6);
    102111void WTFReportArgumentAssertionFailure(const char* file, int line, const char* function, const char* argName, const char* assertion);
    103 void WTFReportFatalError(const char* file, int line, const char* function, const char* format, ...) ;
    104 void WTFReportError(const char* file, int line, const char* function, const char* format, ...);
    105 void WTFLog(WTFLogChannel* channel, const char* format, ...);
    106 void WTFLogVerbose(const char* file, int line, const char* function, WTFLogChannel* channel, const char* format, ...);
     112void WTFReportFatalError(const char* file, int line, const char* function, const char* format, ...) WTF_ATTRIBUTE_PRINTF(4, 5);
     113void WTFReportError(const char* file, int line, const char* function, const char* format, ...) WTF_ATTRIBUTE_PRINTF(4, 5);
     114void WTFLog(WTFLogChannel* channel, const char* format, ...) WTF_ATTRIBUTE_PRINTF(2, 3);
     115void WTFLogVerbose(const char* file, int line, const char* function, WTFLogChannel* channel, const char* format, ...) WTF_ATTRIBUTE_PRINTF(5, 6);
    107116
    108117#ifdef __cplusplus
Note: See TracChangeset for help on using the changeset viewer.