Commit e9503ae9 by Jamie Madill Committed by Commit Bot

Revert "Add compiler printf attribute to relevant functions"

This reverts commit 27a472c6. Reason for revert: Causing failures on 32-bit Linux configs: https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8931673733828416640/+/steps/compile/0/stdout ../../third_party/angle/src/libGLESv2/entry_points_egl.cpp:257:11: error: reinterpret_cast from 'EGLNativeWindowType' (aka 'unsigned long') to 'uintptr_t' (aka 'unsigned int') is not allowed reinterpret_cast<uintptr_t>(win), reinterpret_cast<uintptr_t>(attrib_list)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../third_party/angle/src/common/debug.h:230:112: note: expanded from macro 'EVENT' #define EVENT(message, ...) gl::ScopedPerfEventHelper scopedPerfEventHelper("%s" message "\n", __FUNCTION__, ##__VA_ARGS__); ^~~~~~~~~~~ ../../third_party/angle/src/libGLESv2/entry_points_egl.cpp:314:11: error: reinterpret_cast from 'EGLNativePixmapType' (aka 'unsigned long') to 'uintptr_t' (aka 'unsigned int') is not allowed reinterpret_cast<uintptr_t>(pixmap), reinterpret_cast<uintptr_t>(attrib_list)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Original change's description: > Add compiler printf attribute to relevant functions > > This commit includes fixes to undefined behavior caught by this > attribute. The following changes have been made: > > - 0x%0.8p is changed to %016 PRIxPTR. Both 0 and . have undefined behavior with > p. Additionally, %p already prints 0x with both gcc and clang. This > results in a small output change: > > void *x = (void *)0x1234; > void *y = (void *)0x1234567890abcdef; > > printf("|%0.8p|\n", x); > printf("|%0.8p|\n", y); > > printf("|%016" PRIxPTR "|\n", reinterpret_cast<uintptr_t>(x)); > printf("|%016" PRIxPTR "|\n", reinterpret_cast<uintptr_t>(y)); > > prints: > > |0x00001234| > |0x1234567890abcdef| > |0x0000000000001234| > |0x1234567890abcdef| > > - %d used for GLintptr, GLsizeiptr, EGLTime and EGLnsecsANDROID is > changed to %llu and the relevant argument is cast to unsigned long > long. This is due to these types being typedefs to unknown types (on > Linux for example, these are unsigned long, and my guess would be > unsigned long long on Windows where long is 32 bits). > - %llu is used for GLuint64, which could be unsigned long (as is on > Linux). Those arguments are cast to unsigned long long. > - %p is used for some EGLNative types, but those types may not be a > pointer. Those arguments are cast to uintptr_t and printed as above. > > Bug: angleproject:2928 > Change-Id: I63e9e998c72701ce8582f1ebf25d6374be9090e4 > Reviewed-on: https://chromium-review.googlesource.com/c/1289232 > Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Yuly Novikov <ynovikov@chromium.org> TBR=ynovikov@chromium.org,jmadill@chromium.org,syoussefi@chromium.org Change-Id: I4f3cea64977bee9f889db6c995371bd2bbc6d81b No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: angleproject:2928 Reviewed-on: https://chromium-review.googlesource.com/c/1299480 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 479918de
......@@ -298,34 +298,6 @@ def just_the_name_packed(param, reserved_set):
else:
return name
static_cast_to_dict = {
"GLintptr": "unsigned long long",
"GLsizeiptr": "unsigned long long",
"GLuint64": "unsigned long long",
}
reinterpret_cast_to_dict = {
"GLsync": "uintptr_t",
"GLDEBUGPROC": "uintptr_t",
"GLDEBUGPROCKHR": "uintptr_t",
"GLeglImageOES": "uintptr_t",
}
def param_print_argument(param):
name_only = just_the_name(param)
type_only = just_the_type(param)
if "*" in param:
return "reinterpret_cast<uintptr_t>(" + name_only + ")"
if type_only in reinterpret_cast_to_dict:
return "reinterpret_cast<" + reinterpret_cast_to_dict[type_only] + ">(" + name_only + ")"
if type_only in static_cast_to_dict:
return "static_cast<" + static_cast_to_dict[type_only] + ">(" + name_only + ")"
return name_only
format_dict = {
"GLbitfield": "0x%X",
"GLboolean": "%u",
......@@ -334,22 +306,22 @@ format_dict = {
"GLfixed": "0x%X",
"GLfloat": "%f",
"GLint": "%d",
"GLintptr": "%llu",
"GLintptr": "%d",
"GLshort": "%d",
"GLsizei": "%d",
"GLsizeiptr": "%llu",
"GLsync": "0x%016\" PRIxPTR \"",
"GLsizeiptr": "%d",
"GLsync": "0x%0.8p",
"GLubyte": "%d",
"GLuint": "%u",
"GLuint64": "%llu",
"GLDEBUGPROC": "0x%016\" PRIxPTR \"",
"GLDEBUGPROCKHR": "0x%016\" PRIxPTR \"",
"GLeglImageOES": "0x%016\" PRIxPTR \"",
"GLDEBUGPROC": "0x%0.8p",
"GLDEBUGPROCKHR": "0x%0.8p",
"GLeglImageOES": "0x%0.8p",
}
def param_format_string(param):
if "*" in param:
return param + " = 0x%016\" PRIxPTR \""
return param + " = 0x%0.8p"
else:
type_only = just_the_type(param)
if type_only not in format_dict:
......@@ -386,7 +358,7 @@ def format_entry_point_def(cmd_name, proto, params, is_explicit_context):
packed_gl_enum_conversions += ["\n " + internal_type + " " + internal_name +" = FromGLenum<" +
internal_type + ">(" + name + ");"]
pass_params = [param_print_argument(param) for param in params]
pass_params = [just_the_name(param) for param in params]
format_params = [param_format_string(param) for param in params]
return_type = proto[:-len(cmd_name)]
default_return = default_return_value(cmd_name, return_type.strip())
......
......@@ -297,16 +297,6 @@ std::string ToString(const T &value)
#define ANGLE_NOINLINE
#endif
#if defined(__clang__) || (defined(__GNUC__) && defined(__has_attribute))
#if __has_attribute(format)
#define ANGLE_FORMAT_PRINTF(fmt, args) __attribute__((format(__printf__, fmt, args)))
#else
#define ANGLE_FORMAT_PRINTF(fmt, args)
#endif
#else
#define ANGLE_FORMAT_PRINTF(fmt, args)
#endif
#ifndef ANGLE_STRINGIFY
#define ANGLE_STRINGIFY(x) #x
#endif
......
......@@ -31,8 +31,7 @@ namespace gl
class ScopedPerfEventHelper : angle::NonCopyable
{
public:
ANGLE_FORMAT_PRINTF(2, 3)
ScopedPerfEventHelper(const char *format, ...);
ScopedPerfEventHelper(const char* format, ...);
~ScopedPerfEventHelper();
};
......
......@@ -97,7 +97,6 @@ class VulkanLibrary final : NonCopyable
VkInstance mInstance = VK_NULL_HANDLE;
};
ANGLE_FORMAT_PRINTF(1, 2)
std::string FormatString(const char *fmt, ...)
{
va_list vararg;
......
......@@ -17,7 +17,6 @@
#include "libANGLE/Error.h"
#include "libANGLE/RefCountObject.h"
#include <inttypes.h>
#include <stdint.h>
#include <bitset>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -7,7 +7,6 @@
#include <sstream>
#include <stdarg.h>
ANGLE_FORMAT_PRINTF(1, 2)
static std::vector<char> FormatArg(const char* fmt, ...)
{
va_list vararg;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment