提交 b1edee8a 编写于 作者: S Simon Fels 提交者: GitHub

Merge pull request #22 from vosst/fix-build

Fix build with warnings turned on.
# Don't treat any warnings as error as we take the source directly from
# upstream and just compile it.
set(CMAKE_C_FLAGS "-Wall")
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall")
# Ensure -fPIC
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
include_directories(
${CMAKE_SOURCE_DIR}/src
......
#ifndef __gl_h_
#define __gl_h_
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wredundant-decls"
/* $Revision: 10601 $ on $Date:: 2010-03-04 22:15:27 -0800 #$ */
#include <GLES/glplatform.h>
......@@ -766,5 +768,7 @@ GL_API void GL_APIENTRY glPointSizePointerOES (GLenum type, GLsizei stride, cons
}
#endif
#pragma GCC diagnostic pop
#endif /* __gl_h_ */
......@@ -44,7 +44,7 @@ public:
if (!m_buf || len > m_bufsize) {
int allocLen = m_bufsize < len ? len : m_bufsize;
m_buf = (unsigned char *)allocBuffer(allocLen);
m_buf = static_cast<unsigned char *>(allocBuffer(allocLen));
if (!m_buf)
return NULL;
m_bufsize = m_free = allocLen;
......
......@@ -24,9 +24,9 @@
#define TRACE_CHECKSUMHELPER 0
#if TRACE_CHECKSUMHELPER
#define LOG_CHECKSUMHELPER(x...) fprintf(stderr, x)
#define LOG_CHECKSUMHELPER(...) fprintf(stderr, __VA_ARGS__)
#else
#define LOG_CHECKSUMHELPER(x...)
#define LOG_CHECKSUMHELPER(...)
#endif
// ChecksumCalculator adds checksum as an array of bytes to GL pipe communication, which
......
......@@ -37,5 +37,5 @@ void glUtilsPackPointerData(unsigned char *dst, unsigned char *str,
int glUtilsPixelBitSize(GLenum format, GLenum type);
#ifdef __cplusplus
};
}
#endif
......@@ -14,6 +14,9 @@
* limitations under the License.
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wredundant-decls"
typedef void (*logger_t)(const char* fmt, ...);
extern logger_t emugl_logger;
extern logger_t emugl_cxt_logger;
......@@ -35,3 +38,5 @@ void set_emugl_cxt_logger(logger_t f);
#else
#define GL_LOG(...) 0
#endif
#pragma GCC diagnostic pop
......@@ -19,6 +19,6 @@ enable_testing()
add_definitions(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN -DBOOST_TEST_MODULE=xdg)
add_executable(xdg_test xdg_test.cpp)
set_property(TARGET xdg_test PROPERTY CXX_STANDARD 11)
target_link_libraries(xdg_test xdg)
target_link_libraries(xdg_test xdg ${Boost_LIBRARIES})
add_test(xdg_test xdg_test)
......@@ -26,7 +26,7 @@ anbox::cmds::ContainerManager::ContainerManager()
: CommandWithFlagsAndAction{
cli::Name{"container-manager"}, cli::Usage{"container-manager"},
cli::Description{"Start the container manager service"}} {
action([](const cli::Command::Context& ctxt) {
action([](const cli::Command::Context&) {
auto trap = core::posix::trap_signals_for_process(
{core::posix::Signal::sig_term, core::posix::Signal::sig_int});
trap->signal_raised().connect([trap](const core::posix::Signal& signal) {
......
......@@ -15,6 +15,8 @@
*
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-default"
#include <boost/filesystem.hpp>
#include "core/posix/signal.h"
......@@ -46,6 +48,7 @@
#include <core/dbus/asio/executor.h>
#include <core/dbus/bus.h>
#pragma GCC diagnostic pop
namespace fs = boost::filesystem;
......@@ -82,7 +85,7 @@ anbox::cmds::Run::Run(const BusFactory &bus_factory)
cli::Description{"Icon of the application to run"},
icon_));
action([this](const cli::Command::Context &ctx) {
action([this](const cli::Command::Context &) {
auto trap = core::posix::trap_signals_for_process(
{core::posix::Signal::sig_term, core::posix::Signal::sig_int});
trap->signal_raised().connect([trap](const core::posix::Signal &signal) {
......
......@@ -25,7 +25,7 @@ namespace common {
struct FreeDelete {
template <class T>
void operator()(T ptr) const {
free((void*)ptr);
free(ptr);
}
};
......
......@@ -207,7 +207,7 @@ class SmallVector {
void set_capacity(size_type newCap) {
// Here we can only be switching to the dynamic vector, as static one
// always has its capacity on the maximum.
const auto newBegin = (T*)malloc(sizeof(T) * newCap);
const auto newBegin = static_cast<T*>(malloc(sizeof(T) * newCap));
if (!newBegin) {
abort(); // what else can we do here?
}
......@@ -235,7 +235,7 @@ class SmallVector {
// This function returns that address, and SmallFixedVector<> has a static
// assert to make sure it remains correct.
constexpr const void* smallBufferStart() const {
return (const void*)(&mCapacity + 1);
return static_cast<const void*>(&mCapacity + 1);
}
// Standard set of members for a vector - begin, end and capacity.
......@@ -267,14 +267,6 @@ class SmallFixedVector : public SmallVector<T> {
// Default constructor - set up an empty vector with capacity at full
// internal array size.
SmallFixedVector() {
// Make sure that the small array starts exactly where base class
// expects it: right after the |mCapacity|.
static_assert(offsetof(base, mCapacity) + sizeof(base::mCapacity) ==
offsetof(SmallFixedVector, mData) &&
offsetof(Data, array) == 0,
"SmallFixedVector<> class layout is wrong, "
"|mData| needs to follow |mCapacity|");
init_inplace();
}
......
......@@ -32,7 +32,7 @@ namespace {
// implemented as unsigned integers. These convenience template functions
// help casting between them safely without generating compiler warnings.
inline void* SafePointerFromUInt(unsigned int handle) {
return (void*)(uintptr_t)(handle);
return reinterpret_cast<void*>(static_cast<uintptr_t>(handle));
}
inline unsigned int SafeUIntFromPointer(const void* ptr) {
......@@ -40,7 +40,7 @@ inline unsigned int SafeUIntFromPointer(const void* ptr) {
// Ignore the assert below to avoid crashing when running older
// system images, which might have buggy encoder libraries. Print
// an error message though.
if ((uintptr_t)(ptr) != (unsigned int)(uintptr_t)(ptr)) {
if (reinterpret_cast<uintptr_t>(ptr) != static_cast<unsigned int>(reinterpret_cast<uintptr_t>(ptr))) {
fprintf(stderr, "EmuGL:WARNING: bad generic pointer %p\n", ptr);
}
#else
......@@ -48,7 +48,7 @@ inline unsigned int SafeUIntFromPointer(const void* ptr) {
// in an unsigned integer!
assert((uintptr_t)(ptr) == (unsigned int)(uintptr_t)(ptr));
#endif
return (unsigned int)(uintptr_t)(ptr);
return static_cast<unsigned int>(reinterpret_cast<uintptr_t>(ptr));
}
// Lazily create and bind a framebuffer object to the current host context.
......@@ -181,11 +181,11 @@ ColorBuffer* ColorBuffer::create(EGLDisplay p_display, int p_width,
if (has_eglimage_texture_2d) {
cb->m_eglImage = s_egl.eglCreateImageKHR(
p_display, s_egl.eglGetCurrentContext(), EGL_GL_TEXTURE_2D_KHR,
(EGLClientBuffer)SafePointerFromUInt(cb->m_tex), NULL);
reinterpret_cast<EGLClientBuffer>(SafePointerFromUInt(cb->m_tex)), NULL);
cb->m_blitEGLImage = s_egl.eglCreateImageKHR(
p_display, s_egl.eglGetCurrentContext(), EGL_GL_TEXTURE_2D_KHR,
(EGLClientBuffer)SafePointerFromUInt(cb->m_blitTex), NULL);
reinterpret_cast<EGLClientBuffer>(SafePointerFromUInt(cb->m_blitTex)), NULL);
}
cb->m_resizer = new TextureResize(p_width, p_height);
......
......@@ -21,7 +21,7 @@
ReadBuffer::ReadBuffer(size_t bufsize) {
m_size = bufsize;
m_buf = (unsigned char*)malloc(m_size * sizeof(unsigned char));
m_buf = static_cast<unsigned char*>(malloc(m_size * sizeof(unsigned char)));
m_validData = 0;
m_readPtr = m_buf;
}
......@@ -43,7 +43,7 @@ int ReadBuffer::getData(IOStream* stream) {
new_size = INT_MAX;
}
new_buf = (unsigned char*)realloc(m_buf, new_size);
new_buf = static_cast<unsigned char*>(realloc(m_buf, new_size));
if (!new_buf) {
ERR("Failed to alloc %zu bytes for ReadBuffer\n", new_size);
return -1;
......
......@@ -49,8 +49,8 @@ static EGLint rcGetEGLVersion(EGLint *major, EGLint *minor) {
if (!renderer)
return EGL_FALSE;
*major = (EGLint)renderer->getCaps().eglMajor;
*minor = (EGLint)renderer->getCaps().eglMinor;
*major = static_cast<EGLint>(renderer->getCaps().eglMajor);
*minor = static_cast<EGLint>(renderer->getCaps().eglMinor);
return EGL_TRUE;
}
......@@ -69,7 +69,7 @@ static EGLint rcQueryEGLString(EGLenum name, void *buffer, EGLint bufferSize) {
return -len;
}
strcpy((char *)buffer, str);
strcpy(static_cast<char *>(buffer), str);
return len;
}
......@@ -131,7 +131,7 @@ static EGLint rcGetNumConfigs(uint32_t *p_numAttribs) {
}
static EGLint rcGetConfigs(uint32_t bufSize, GLuint *buffer) {
GLuint bufferSize = (GLuint)bufSize;
GLuint bufferSize = static_cast<GLuint>(bufSize);
return renderer->getConfigs()->packConfigs(bufferSize, buffer);
}
......@@ -140,8 +140,8 @@ static EGLint rcChooseConfig(EGLint *attribs, uint32_t attribs_size,
if (!renderer || attribs_size == 0)
return 0;
return renderer->getConfigs()->chooseConfig(attribs, (EGLint *)configs,
(EGLint)configs_size);
return renderer->getConfigs()->chooseConfig(attribs, reinterpret_cast<EGLint *>(configs),
static_cast<EGLint>(configs_size));
}
static EGLint rcGetFBParam(EGLint param) {
......@@ -269,9 +269,9 @@ static EGLint rcMakeCurrent(uint32_t context, uint32_t drawSurf,
return (ret ? EGL_TRUE : EGL_FALSE);
}
static void rcFBPost(uint32_t colorBuffer) { WARNING("Not implemented"); }
static void rcFBPost(uint32_t) { WARNING("Not implemented"); }
static void rcFBSetSwapInterval(EGLint interval) {
static void rcFBSetSwapInterval(EGLint) {
// XXX: TBD - should be implemented
}
......@@ -289,8 +289,8 @@ static void rcBindRenderbuffer(uint32_t colorBuffer) {
renderer->bindColorBufferToRenderbuffer(colorBuffer);
}
static EGLint rcColorBufferCacheFlush(uint32_t colorBuffer, EGLint postCount,
int forRead) {
static EGLint rcColorBufferCacheFlush(uint32_t, EGLint,
int) {
// XXX: TBD - should be implemented
return 0;
}
......@@ -329,7 +329,7 @@ static int rcDestroyClientImage(uint32_t image) {
return renderer->destroyClientImage(image);
}
static void rcSelectChecksumCalculator(uint32_t protocol, uint32_t reserved) {
static void rcSelectChecksumCalculator(uint32_t protocol, uint32_t) {
ChecksumCalculatorThreadInfo::setVersion(protocol);
}
......
......@@ -101,7 +101,7 @@ static char *getGLES1ExtensionString(EGLDisplay p_dpy) {
return NULL;
}
DBG("%s: Found config %p\n", __FUNCTION__, (void *)config);
DBG("%s: Found config %p\n", __FUNCTION__, reinterpret_cast<void *>(config));
static const EGLint pbufAttribs[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE};
......@@ -130,7 +130,7 @@ static char *getGLES1ExtensionString(EGLDisplay p_dpy) {
}
// the string pointer may become invalid when the context is destroyed
const char *s = (const char *)s_gles1.glGetString(GL_EXTENSIONS);
const char *s = reinterpret_cast<const char *>(s_gles1.glGetString(GL_EXTENSIONS));
char *extString = strdup(s ? s : "");
s_egl.eglMakeCurrent(p_dpy, NULL, NULL, NULL);
......@@ -273,7 +273,7 @@ bool Renderer::initialize(EGLNativeDisplayType nativeDisplay) {
if (has_gl_oes_image) {
has_gl_oes_image &= strstr(gles1Extensions, "GL_OES_EGL_image") != NULL;
}
free((void *)gles1Extensions);
free(gles1Extensions);
gles1Extensions = NULL;
const char *eglExtensions =
......@@ -351,9 +351,9 @@ bool Renderer::initialize(EGLNativeDisplayType nativeDisplay) {
// Cache the GL strings so we don't have to think about threading or
// current-context when asked for them.
//
m_glVendor = (const char *)s_gles2.glGetString(GL_VENDOR);
m_glRenderer = (const char *)s_gles2.glGetString(GL_RENDERER);
m_glVersion = (const char *)s_gles2.glGetString(GL_VERSION);
m_glVendor = reinterpret_cast<const char *>(s_gles2.glGetString(GL_VENDOR));
m_glRenderer = reinterpret_cast<const char *>(s_gles2.glGetString(GL_RENDERER));
m_glVersion = reinterpret_cast<const char *>(s_gles2.glGetString(GL_VERSION));
m_textureDraw = new TextureDraw(m_eglDisplay);
if (!m_textureDraw) {
......@@ -831,7 +831,7 @@ HandleType Renderer::createClientImage(HandleType context, EGLenum target,
s_egl.eglCreateImageKHR(m_eglDisplay, eglContext, target,
reinterpret_cast<EGLClientBuffer>(buffer), NULL);
return (HandleType) reinterpret_cast<uintptr_t>(image);
return static_cast<HandleType>(reinterpret_cast<uintptr_t>(image));
}
EGLBoolean Renderer::destroyClientImage(HandleType image) {
......@@ -1022,7 +1022,9 @@ void Renderer::draw(RendererWindow *window, const Renderable &renderable,
s_gles2.glEnableVertexAttribArray(prog.texcoord_attr);
m_primitives.clear();
tessellate(m_primitives, {cb->getWidth(), cb->getHeight()}, renderable);
tessellate(m_primitives, {
static_cast<int32_t>(cb->getWidth()),
static_cast<int32_t>(cb->getHeight())}, renderable);
for (auto const &p : m_primitives) {
cb->bind();
......
......@@ -90,7 +90,7 @@ RendererConfigList::RendererConfigList(EGLDisplay display)
: mCount(0), mConfigs(NULL), mDisplay(display) {
if (display == EGL_NO_DISPLAY) {
E("%s: Invalid display value %p (EGL_NO_DISPLAY)\n", __FUNCTION__,
(void*)display);
reinterpret_cast<void*>(display));
return;
}
......@@ -199,7 +199,7 @@ int RendererConfigList::chooseConfig(const EGLint* attribs, EGLint* configs,
if (guestConfigId == hostConfigId) {
// There is a match. Write it to |configs| if it is not NULL.
if (configs && result < configsSize) {
configs[result] = (uint32_t)k;
configs[result] = static_cast<uint32_t>(k);
}
result++;
break;
......
......@@ -54,7 +54,7 @@ class RendererConfig {
// Get the EGL_CONFIG_ID value. This is the same as the one of the
// underlying host EGLConfig handle.
GLint getConfigId() const { return (GLint)getAttribValue(4); }
GLint getConfigId() const { return static_cast<GLint>(getAttribValue(4)); }
private:
RendererConfig();
......
......@@ -189,13 +189,7 @@ static void attachShaders(TextureResize::Framebuffer* fb,
TextureResize::TextureResize(GLuint width, GLuint height)
: mWidth(width),
mHeight(height),
mFactor(1),
mFBWidth({
0,
}),
mFBHeight({
0,
}) {
mFactor(1) {
s_gles2.glGenTextures(1, &mFBWidth.texture);
s_gles2.glBindTexture(GL_TEXTURE_2D, mFBWidth.texture);
s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
......
......@@ -28,11 +28,11 @@ class TextureResize {
GLuint update(GLuint texture);
struct Framebuffer {
GLuint texture;
GLuint framebuffer;
GLuint program;
GLuint aPosition;
GLuint uTexture;
GLuint texture = 0;
GLuint framebuffer = 0;
GLuint program = 0;
GLuint aPosition = 0;
GLuint uTexture = 0;
};
private:
......
......@@ -152,7 +152,7 @@ bool WindowSurface::resize(unsigned int p_width, unsigned int p_height) {
// Create pbuffer surface.
//
const EGLint pbufAttribs[5] = {
EGL_WIDTH, (EGLint)p_width, EGL_HEIGHT, (EGLint)p_height, EGL_NONE,
EGL_WIDTH, static_cast<EGLint>(p_width), EGL_HEIGHT, static_cast<EGLint>(p_height), EGL_NONE,
};
mSurface = s_egl.eglCreatePbufferSurface(mDisplay, mConfig, pbufAttribs);
......
......@@ -57,6 +57,8 @@ std::string client_type_to_string(
return "boot-animation";
case anbox::qemu::PipeConnectionCreator::client_type::invalid:
break;
default:
break;
}
return "unknown";
}
......
......@@ -71,7 +71,7 @@ void QemudMessageProcessor::process_commands() {
void QemudMessageProcessor::send_header(const size_t &size) {
char header[header_size + 1];
std::snprintf(header, header_size + 1, "%04x", size);
std::snprintf(header, header_size + 1, "%04lu", size);
messenger_->send(header, header_size);
}
......
......@@ -58,8 +58,8 @@ class MessageProcessor : public network::MessageProcessor {
void send_response(::google::protobuf::uint32 id,
google::protobuf::MessageLite* response);
virtual void dispatch(Invocation const& invocation) {}
virtual void process_event_sequence(const std::string& event) {}
virtual void dispatch(Invocation const&) {}
virtual void process_event_sequence(const std::string&) {}
private:
std::shared_ptr<network::MessageSender> sender_;
......
......@@ -72,7 +72,7 @@ void AudioSink::disconnect_audio() {
void AudioSink::read_data(std::uint8_t *buffer, int size) {
std::unique_lock<std::mutex> l(lock_);
const auto wanted = size;
size_t count = 0;
int count = 0;
auto dst = buffer;
while (count < wanted) {
......
......@@ -14,8 +14,10 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-default"
#include "anbox/ubuntu/keycode_converter.h"
#pragma GCC diagnostic pop
#include <linux/input.h>
......
......@@ -15,6 +15,8 @@
*
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-default"
#include "anbox/ubuntu/platform_policy.h"
#include "anbox/bridge/android_api_stub.h"
#include "anbox/input/device.h"
......@@ -28,6 +30,7 @@
#include <signal.h>
#include <sys/types.h>
#pragma GCC diagnostic pop
namespace anbox {
namespace ubuntu {
......@@ -123,6 +126,8 @@ void PlatformPolicy::process_events() {
case SDL_KEYUP:
process_input_event(event);
break;
default:
break;
}
}
}
......
......@@ -15,6 +15,8 @@
*
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-default"
#include "anbox/ubuntu/window.h"
#include "anbox/logger.h"
#include "anbox/wm/window_state.h"
......@@ -22,6 +24,7 @@
#include <boost/throw_exception.hpp>
#include <SDL_syswm.h>
#pragma GCC diagnostic pop
namespace anbox {
namespace ubuntu {
......@@ -93,6 +96,8 @@ void Window::process_event(const SDL_Event &event) {
case SDL_WINDOWEVENT_CLOSE:
if (observer_) observer_->window_deleted(id_);
break;
default:
break;
}
}
......
......@@ -124,7 +124,7 @@ class TestThread final {
// Call end_pop() to get the command's result, as well as the popped
// buffer if it is 0.
bool start_pop() {
input_.send(Request{Cmd::Pop});
input_.send(Request{Cmd::Pop, Buffer{}});
return true;
}
......@@ -140,12 +140,12 @@ class TestThread final {
// Tell the test thread to close the queue from its side.
void do_close() {
input_.send(Request{Cmd::Close});
input_.send(Request{Cmd::Close, Buffer{}});
}
// Tell the test thread to stop after completing its current command.
void stop() {
input_.send(Request{Cmd::Stop});
input_.send(Request{Cmd::Stop, Buffer{}});
thread_.join();
}
......
......@@ -130,10 +130,11 @@ TEST(BufferedIOStream, ReadWithNoDataAvailable) {
}
});
size_t size{10};
constexpr size_t size{10};
std::uint8_t read_data[size] = {0x0};
EXPECT_NE(nullptr, stream.read(read_data, &size));
EXPECT_EQ(2, size);
size_t read = 10;
EXPECT_NE(nullptr, stream.read(read_data, &read));
EXPECT_EQ(2, read);
EXPECT_EQ(0x12, read_data[0]);
EXPECT_EQ(0x34, read_data[1]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册