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