changeset 73:efe1a7fb43f8

Misc: fix some code style
author David Demelier <markand@malikania.fr>
date Thu, 22 Dec 2016 09:27:09 +0100
parents b43f40857609
children 78de82cc6bde
files libclient-js/malikania/js_line.cpp libclient-js/malikania/js_rectangle.cpp libclient/malikania/backend/sdl/window_backend.cpp libclient/malikania/client_resources_loader.cpp libcommon/malikania/util.cpp
diffstat 5 files changed, 37 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/libclient-js/malikania/js_line.cpp	Thu Dec 22 09:13:01 2016 +0100
+++ b/libclient-js/malikania/js_line.cpp	Thu Dec 22 09:27:09 2016 +0100
@@ -74,8 +74,9 @@
 line dukx_require_line(duk_context* ctx, duk_idx_t index)
 {
     auto get = [&] (auto prop) {
-        if (!duk_has_prop_string(ctx, index, prop))
+        if (!duk_has_prop_string(ctx, index, prop)) {
             duk_error(ctx, DUK_ERR_ERROR, "missing %s property in line description", prop);
+        }
 
         duk_get_prop_string(ctx, index, prop);
 
--- a/libclient-js/malikania/js_rectangle.cpp	Thu Dec 22 09:13:01 2016 +0100
+++ b/libclient-js/malikania/js_rectangle.cpp	Thu Dec 22 09:27:09 2016 +0100
@@ -27,10 +27,11 @@
 unsigned clamp(duk_context* ctx, int value, bool required)
 {
     if (value < 0) {
-        if (required)
+        if (required) {
             duk_error(ctx, DUK_ERR_RANGE_ERROR, "%d can not be negative", value);
-        else
+        } else {
             value = 0;
+        }
     }
 
     return static_cast<unsigned>(value);
@@ -42,8 +43,9 @@
 
     if (duk_is_object(ctx, index)) {
         auto get = [&] (auto prop) {
-            if (required && !duk_has_prop_string(ctx, index, prop))
+            if (required && !duk_has_prop_string(ctx, index, prop)) {
                 duk_error(ctx, DUK_ERR_ERROR, "missing '%s' property", prop);
+            }
 
             duk_get_prop_string(ctx, index, prop);
 
@@ -61,8 +63,9 @@
 
         rect = rectangle(get("x"), get("y"),
             clamp(ctx, get("width"), required), clamp(ctx, get("height"), required));
-    } else if (required)
+    } else if (required) {
         duk_error(ctx, DUK_ERR_TYPE_ERROR, "rectangle object expected");
+    }
 
     return rect;
 }
@@ -78,8 +81,9 @@
             clamp(ctx, duk_require_int(ctx, 2), true),
             clamp(ctx, duk_require_int(ctx, 3), true)
         );
-    } else if (duk_get_top(ctx) == 1)
+    } else if (duk_get_top(ctx) == 1) {
         rect = parse(ctx, 0, true);
+    }
 
     duk_ret_t ret;
 
--- a/libclient/malikania/backend/sdl/window_backend.cpp	Thu Dec 22 09:13:01 2016 +0100
+++ b/libclient/malikania/backend/sdl/window_backend.cpp	Thu Dec 22 09:27:09 2016 +0100
@@ -398,7 +398,13 @@
     SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO);
 
     m_window = {
-        SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_OPENGL),
+        SDL_CreateWindow(
+            title.c_str(),
+            SDL_WINDOWPOS_UNDEFINED,
+            SDL_WINDOWPOS_UNDEFINED,
+            width, height,
+            SDL_WINDOW_OPENGL
+        ),
         SDL_DestroyWindow
     };
 
--- a/libclient/malikania/client_resources_loader.cpp	Thu Dec 22 09:13:01 2016 +0100
+++ b/libclient/malikania/client_resources_loader.cpp	Thu Dec 22 09:27:09 2016 +0100
@@ -122,7 +122,8 @@
         auto delay = it->find("delay");
 
         if (delay == it->end() || !delay->is_number_integer()) {
-            throw std::runtime_error(id + ": frame " + std::to_string(index) + ": missing 'delay' property (int expected)");
+            throw std::runtime_error(id + ": frame " + std::to_string(index) +
+                ": missing 'delay' property (int expected)");
         }
 
         frames.emplace_back(delay->get<int>());
--- a/libcommon/malikania/util.cpp	Thu Dec 22 09:13:01 2016 +0100
+++ b/libcommon/malikania/util.cpp	Thu Dec 22 09:27:09 2016 +0100
@@ -70,8 +70,9 @@
 
     auto size = readlink("/proc/self/exe", &result[0], 2048);
 
-    if (size < 0)
+    if (size < 0) {
         throw std::runtime_error(std::strerror(errno));
+    }
 
     result.resize(size, '\0');
 
@@ -88,8 +89,9 @@
 
     result.resize(size, '\0');
 
-    if (sysctl(mib.data(), 4, &result[0], &size, nullptr, 0) < 0)
+    if (sysctl(mib.data(), 4, &result[0], &size, nullptr, 0) < 0) {
         throw std::runtime_error(std::strerror(errno));
+    }
 
     result.resize(size, '\0');
 
@@ -105,8 +107,9 @@
 
     result.resize(size, '\0');
 
-    if ((size = proc_pidpath(getpid(), &result[0], size)) == 0)
+    if ((size = proc_pidpath(getpid(), &result[0], size)) == 0) {
         throw std::runtime_error(std::strerror(errno));
+    }
 
     result.resize(size, '\0');
 
@@ -122,8 +125,9 @@
 
     result.resize(size, '\0');
 
-    if (!(size = GetModuleFileNameA(nullptr, &result[0], size)))
+    if (!(size = GetModuleFileNameA(nullptr, &result[0], size))) {
         throw std::runtime_error("GetModuleFileName error");
+    }
 
     result.resize(size, '\0');
 
@@ -142,8 +146,9 @@
 
         result.resize(size, '\0');
 
-        if (sysctl(mib.data(), 4, &result[0], &size, nullptr, 0) < 0)
+        if (sysctl(mib.data(), 4, &result[0], &size, nullptr, 0) < 0) {
                 throw std::runtime_error(std::strerror(errno));
+        }
 
         result.resize(size, '\0');
 #else
@@ -151,8 +156,9 @@
 
         auto size = readlink("/proc/curproc/exe", &result[0], 2048);
 
-        if (size < 0)
+        if (size < 0) {
                 throw std::runtime_error(std::strerror(errno));
+        }
 
         result.resize(size, '\0');
 #endif
@@ -169,10 +175,12 @@
     std::size_t len;
     std::array<int, 4> mib{ CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV };
 
-    if (sysctl(mib.data(), 4, nullptr, &len, nullptr, 0) == -1)
+    if (sysctl(mib.data(), 4, nullptr, &len, nullptr, 0) == -1) {
         throw std::runtime_error(std::strerror(errno));
-    if ((paths = static_cast<char **>(malloc(len))) == nullptr)
+    }
+    if ((paths = static_cast<char **>(malloc(len))) == nullptr) {
         throw std::runtime_error(std::strerror(errno));
+    }
 
     sysctl(mib.data(), 4, paths, &len, nullptr, 0);
 
@@ -194,7 +202,7 @@
 
 std::string executable_path()
 {
-    /* Not supported */
+    // Not supported.
     return "";
 }