widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #11538
[Merge] lp:~widelands-dev/widelands/clang-tidy-round1 into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/clang-tidy-round1 into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1731034 in widelands: "Use clang-tidy to clean up the codebase"
https://bugs.launchpad.net/widelands/+bug/1731034
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/clang-tidy-round1/+merge/333560
Fixed some warnings flagged up by clang-tidy:
cert-dcl03-c
cert-err52-cpp
cert-err61-cpp
clang-analyzer-core.CallAndMessage
clang-analyzer-core.DivideZero
clang-analyzer-core.NonNullParamChecker
clang-analyzer-core.NullDereference
clang-analyzer-core.UndefinedBinaryOperatorResult
clang-analyzer-deadcode.DeadStores
clang-analyzer-security.insecureAPI.strcpy
clang-diagnostic-unused-const-variable
google-explicit-constructor
misc-assert-side-effect
misc-static-assert
readability-function-size
readability-redundant-smartptr-get
readability-uniqueptr-delete-release
There is 1 instance of clang-analyzer-core.CallAndMessage remaining.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/clang-tidy-round1 into lp:widelands.
=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc 2017-11-04 23:59:03 +0000
+++ src/ai/defaultai.cc 2017-11-10 19:17:16 +0000
@@ -66,7 +66,6 @@
// following two are used for roads management, for creating shortcuts and dismantling dispensable
// roads
-constexpr int32_t kSpotsTooLittle = 15;
constexpr int32_t kSpotsEnough = 25;
constexpr uint16_t kTargetQuantCap = 30;
@@ -5448,7 +5447,7 @@
}
}
- return existing / total;
+ return (total > 0) ? (existing / total) : 0;
}
// \returns the building observer
=== modified file 'src/economy/expedition_bootstrap.cc'
--- src/economy/expedition_bootstrap.cc 2017-03-04 06:55:30 +0000
+++ src/economy/expedition_bootstrap.cc 2017-11-10 19:17:16 +0000
@@ -127,7 +127,7 @@
InputQueue& ExpeditionBootstrap::inputqueue(DescriptionIndex index, WareWorker type) const {
for (const std::unique_ptr<InputQueue>& iq : queues_) {
if (iq->get_index() == index && iq->get_type() == type) {
- return *iq.get();
+ return *iq;
}
}
NEVER_HERE();
=== modified file 'src/economy/flag.cc'
--- src/economy/flag.cc 2017-04-23 12:11:19 +0000
+++ src/economy/flag.cc 2017-11-10 19:17:16 +0000
@@ -82,7 +82,7 @@
auto should_be_deleted = [&egbase, this](const OPtr<Worker>& r) {
Worker& worker = *r.get(egbase);
Bob::State const* const state = worker.get_state(Worker::taskWaitforcapacity);
- if (!state) {
+ if (state == nullptr) {
log("WARNING: worker %u is in the capacity wait queue of flag %u but "
"does not have a waitforcapacity task! Removing from queue.\n",
worker.serial(), serial());
=== modified file 'src/economy/portdock.cc'
--- src/economy/portdock.cc 2017-08-01 12:05:49 +0000
+++ src/economy/portdock.cc 2017-11-10 19:17:16 +0000
@@ -60,7 +60,7 @@
}
PortDock::~PortDock() {
- assert(expedition_bootstrap_.get() == nullptr);
+ assert(expedition_bootstrap_ == nullptr);
}
/**
@@ -315,7 +315,7 @@
}
if (expedition_ready_) {
- assert(expedition_bootstrap_.get() != nullptr);
+ assert(expedition_bootstrap_ != nullptr);
// Only use an empty ship.
if (ship.get_nritems() < 1) {
@@ -413,7 +413,7 @@
/// \returns whether an expedition was started or is even ready
bool PortDock::expedition_started() {
- return (expedition_bootstrap_.get() != nullptr) || expedition_ready_;
+ return (expedition_bootstrap_ != nullptr) || expedition_ready_;
}
/// Start an expedition
@@ -561,7 +561,7 @@
}
// Expedition specific stuff
- fw.unsigned_8(expedition_bootstrap_.get() != nullptr ? 1 : 0);
+ fw.unsigned_8(expedition_bootstrap_ != nullptr ? 1 : 0);
fw.unsigned_8(expedition_ready_ ? 1 : 0);
}
=== modified file 'src/economy/test/test_routing.cc'
--- src/economy/test/test_routing.cc 2017-06-20 10:42:00 +0000
+++ src/economy/test/test_routing.cc 2017-11-10 19:17:16 +0000
@@ -43,7 +43,7 @@
class BadAccess : public std::exception {};
class TestingRoutingNode : public RoutingNode {
public:
- TestingRoutingNode(int32_t wcost = 0, Coords pos = Coords(0, 0))
+ explicit TestingRoutingNode(int32_t wcost = 0, Coords pos = Coords(0, 0))
: waitcost_(wcost), position_(pos) {
}
void add_neighbour(TestingRoutingNode* nb) {
=== modified file 'src/editor/editorinteractive.cc'
--- src/editor/editorinteractive.cc 2017-09-13 07:27:00 +0000
+++ src/editor/editorinteractive.cc 2017-11-10 19:17:16 +0000
@@ -73,7 +73,8 @@
undo_(nullptr),
redo_(nullptr),
tools_(new Tools()),
- history_(new EditorHistory(*undo_, *redo_)) {
+ history_(nullptr) // history needs the undo/redo buttons
+{
add_toolbar_button("wui/menus/menu_toggle_menu", "menu", _("Main Menu"), &mainmenu_, true);
mainmenu_.open_window = [this] { new EditorMainMenu(*this, mainmenu_); };
@@ -125,9 +126,11 @@
toolbar()->add_space(15);
undo_ = add_toolbar_button("wui/editor/editor_undo", "undo", _("Undo"));
+ redo_ = add_toolbar_button("wui/editor/editor_redo", "redo", _("Redo"));
+
+ history_.reset(new EditorHistory(*undo_, *redo_));
+
undo_->sigclicked.connect([this] { history_->undo_action(egbase().world()); });
-
- redo_ = add_toolbar_button("wui/editor/editor_redo", "redo", _("Redo"));
redo_->sigclicked.connect([this] { history_->redo_action(egbase().world()); });
toolbar()->add_space(15);
=== modified file 'src/game_io/game_interactive_player_packet.cc'
--- src/game_io/game_interactive_player_packet.cc 2017-08-17 15:34:45 +0000
+++ src/game_io/game_interactive_player_packet.cc 2017-11-10 19:17:16 +0000
@@ -145,16 +145,18 @@
}
// Display flags
- fw.unsigned_32(ibase ? ibase->get_display_flags() : 0);
+ fw.unsigned_32(ibase != nullptr ? ibase->get_display_flags() : 0);
// Map landmarks
- const std::vector<QuickNavigation::Landmark>& landmarks = ibase->landmarks();
- fw.unsigned_8(landmarks.size());
- for (const QuickNavigation::Landmark& landmark : landmarks) {
- fw.unsigned_8(landmark.set ? 1 : 0);
- fw.float_32(landmark.view.viewpoint.x);
- fw.float_32(landmark.view.viewpoint.y);
- fw.float_32(landmark.view.zoom);
+ if (ibase != nullptr) {
+ const std::vector<QuickNavigation::Landmark>& landmarks = ibase->landmarks();
+ fw.unsigned_8(landmarks.size());
+ for (const QuickNavigation::Landmark& landmark : landmarks) {
+ fw.unsigned_8(landmark.set ? 1 : 0);
+ fw.float_32(landmark.view.viewpoint.x);
+ fw.float_32(landmark.view.viewpoint.y);
+ fw.float_32(landmark.view.zoom);
+ }
}
fw.write(fs, "binary/interactive_player");
=== modified file 'src/game_io/game_preload_packet.cc'
--- src/game_io/game_preload_packet.cc 2017-11-04 20:02:46 +0000
+++ src/game_io/game_preload_packet.cc 2017-11-10 19:17:16 +0000
@@ -122,7 +122,7 @@
}
std::unique_ptr<::StreamWrite> sw(fs.open_stream_write(kMinimapFilename));
- if (sw.get() != nullptr) {
+ if (sw != nullptr) {
const MiniMapLayer layers =
MiniMapLayer::Owner | MiniMapLayer::Building | MiniMapLayer::Terrain;
std::unique_ptr<Texture> texture;
=== modified file 'src/graphic/animation.cc'
--- src/graphic/animation.cc 2017-07-03 19:24:02 +0000
+++ src/graphic/animation.cc 2017-11-10 19:17:16 +0000
@@ -328,7 +328,7 @@
if (!id || id > animations_.size())
throw wexception("Requested unknown animation with id: %i", id);
- return *animations_[id - 1].get();
+ return *animations_[id - 1];
}
const Image* AnimationManager::get_representative_image(uint32_t id, const RGBColor* clr) {
=== modified file 'src/graphic/font_handler1.cc'
--- src/graphic/font_handler1.cc 2017-06-24 08:47:46 +0000
+++ src/graphic/font_handler1.cc 2017-11-10 19:17:16 +0000
@@ -86,7 +86,7 @@
uint16_t w = 0) override {
const std::string hash = boost::lexical_cast<std::string>(w) + text;
std::shared_ptr<const RenderedText> rendered_text = render_cache_->get(hash);
- if (rendered_text.get() == nullptr) {
+ if (rendered_text == nullptr) {
rendered_text = render_cache_->insert(hash, rt_renderer_->render(text, w));
}
return rendered_text;
=== modified file 'src/graphic/image_io.cc'
--- src/graphic/image_io.cc 2017-08-18 17:32:16 +0000
+++ src/graphic/image_io.cc 2017-11-10 19:17:16 +0000
@@ -96,7 +96,7 @@
}
// Set jump for error
- if (setjmp(png_jmpbuf(png_ptr))) {
+ if (setjmp(png_jmpbuf(png_ptr))) { // NOLINT
png_destroy_write_struct(&png_ptr, &info_ptr);
throw wexception("save_to_png: Error writing PNG!");
}
=== modified file 'src/graphic/text/bidi.cc'
--- src/graphic/text/bidi.cc 2017-08-09 19:25:04 +0000
+++ src/graphic/text/bidi.cc 2017-11-10 19:17:16 +0000
@@ -588,9 +588,9 @@
}
const icu::UnicodeString parseme(input, "UTF-8");
icu::UnicodeString queue;
- UChar not_a_character = 0xFFFF;
- UChar next = not_a_character;
- UChar previous = not_a_character;
+ const UChar not_a_character = 0xFFFF;
+ UChar next;
+ UChar previous;
for (int i = parseme.length() - 1; i >= 0; --i) {
UChar c = parseme.charAt(i);
@@ -607,16 +607,12 @@
if (kArabicLegacyDiacritics.count(previous) == 1) {
previous = kArabicLegacyDiacritics.at({previous});
}
- if (kArabicLegacyDiacritics.count(next) == 1) {
- next = kArabicLegacyDiacritics.at({next});
- }
// Special ligature forms combine 2 letters.
if (kArabicLigatures.count({previous, c}) == 1) {
c = kArabicLigatures.at({previous, c});
// Now skip 1 letter, since we have just combined 2 letters
--i;
- previous = (i > 0) ? parseme.charAt(i - 1) : not_a_character;
}
} catch (const std::out_of_range& e) {
log("Error trying to fetch Arabic diacritic form: %s\n", e.what());
=== modified file 'src/graphic/text/rendered_text.cc'
--- src/graphic/text/rendered_text.cc 2017-05-23 21:32:20 +0000
+++ src/graphic/text/rendered_text.cc 2017-11-10 19:17:16 +0000
@@ -79,7 +79,7 @@
}
const Image* RenderedRect::image() const {
- assert(permanent_image_ == nullptr || transient_image_.get() == nullptr);
+ assert(permanent_image_ == nullptr || transient_image_ == nullptr);
return permanent_image_ == nullptr ? transient_image_.get() : permanent_image_;
}
@@ -165,7 +165,7 @@
// Blit the rects
for (const auto& rect : rects) {
- blit_rect(dst, offset_x, aligned_pos, *rect.get(), region, align, cropmode);
+ blit_rect(dst, offset_x, aligned_pos, *rect, region, align, cropmode);
}
}
=== modified file 'src/graphic/text/rt_render.cc'
--- src/graphic/text/rt_render.cc 2017-08-18 14:27:26 +0000
+++ src/graphic/text/rt_render.cc 2017-11-10 19:17:16 +0000
@@ -553,7 +553,7 @@
UI::RenderedText* TextNode::render(TextureCache* texture_cache) {
auto rendered_image =
font_.render(txt_, nodestyle_.font_color, nodestyle_.font_style, texture_cache);
- assert(rendered_image.get() != nullptr);
+ assert(rendered_image != nullptr);
UI::RenderedText* rendered_text = new UI::RenderedText();
rendered_text->rects.push_back(
std::unique_ptr<UI::RenderedRect>(new UI::RenderedRect(rendered_image)));
@@ -599,7 +599,7 @@
.str();
std::shared_ptr<const Image> rendered_image = texture_cache->get(hash);
- if (rendered_image.get() == nullptr) {
+ if (rendered_image == nullptr) {
std::shared_ptr<const Image> ttf =
font_.render(txt_, nodestyle_.font_color, nodestyle_.font_style, texture_cache);
auto texture = std::make_shared<Texture>(width(), height());
@@ -610,7 +610,7 @@
}
rendered_image = texture_cache->insert(hash, std::move(texture));
}
- assert(rendered_image.get() != nullptr);
+ assert(rendered_image != nullptr);
rendered_text->rects.push_back(
std::unique_ptr<UI::RenderedRect>(new UI::RenderedRect(rendered_image)));
return rendered_text;
@@ -638,12 +638,12 @@
UI::RenderedText* rendered_text = new UI::RenderedText();
const std::string hash = (boost::format("rt:wsp:%i:%i") % width() % height()).str();
std::shared_ptr<const Image> rendered_image = texture_cache->get(hash);
- if (rendered_image.get() == nullptr) {
+ if (rendered_image == nullptr) {
auto texture = std::make_shared<Texture>(width(), height());
texture->fill_rect(Rectf(0.f, 0.f, w_, h_), RGBAColor(0xcc, 0, 0, 0xcc));
rendered_image = texture_cache->insert(hash, std::move(texture));
}
- assert(rendered_image.get() != nullptr);
+ assert(rendered_image != nullptr);
rendered_text->rects.push_back(
std::unique_ptr<UI::RenderedRect>(new UI::RenderedRect(rendered_image)));
return rendered_text;
@@ -719,7 +719,7 @@
.str();
std::shared_ptr<const Image> rendered_image = texture_cache->get(hash);
- if (rendered_image.get() == nullptr) {
+ if (rendered_image == nullptr) {
// Draw background image (tiling)
auto texture = std::make_shared<Texture>(width(), height());
if (background_image_ != nullptr) {
@@ -737,7 +737,7 @@
}
rendered_image = texture_cache->insert(hash, std::move(texture));
}
- assert(rendered_image.get() != nullptr);
+ assert(rendered_image != nullptr);
rendered_text->rects.push_back(
std::unique_ptr<UI::RenderedRect>(new UI::RenderedRect(rendered_image)));
return rendered_text;
@@ -935,14 +935,14 @@
(use_playercolor_ ? color_.hex_value() : "") % width() % height())
.str();
std::shared_ptr<const Image> rendered_image = texture_cache->get(hash);
- if (rendered_image.get() == nullptr) {
+ if (rendered_image == nullptr) {
auto texture = std::make_shared<Texture>(width(), height());
texture->blit(Rectf(0.f, 0.f, width(), height()), *image_,
Rectf(0.f, 0.f, image_->width(), image_->height()), 1., BlendMode::Copy);
rendered_image = texture_cache->insert(hash, std::move(texture));
}
- assert(rendered_image.get() != nullptr);
+ assert(rendered_image != nullptr);
rendered_text->rects.push_back(
std::unique_ptr<UI::RenderedRect>(new UI::RenderedRect(rendered_image)));
}
=== modified file 'src/graphic/text/sdl_ttf_font.cc'
--- src/graphic/text/sdl_ttf_font.cc 2017-05-21 18:15:17 +0000
+++ src/graphic/text/sdl_ttf_font.cc 2017-11-10 19:17:16 +0000
@@ -72,7 +72,7 @@
static_cast<int>(clr.r) % static_cast<int>(clr.g) % static_cast<int>(clr.b) % style)
.str();
std::shared_ptr<const Image> rv = texture_cache->get(hash);
- if (rv.get() != nullptr) {
+ if (rv != nullptr) {
return rv;
}
=== modified file 'src/graphic/text/test/render_richtext.cc'
--- src/graphic/text/test/render_richtext.cc 2017-05-25 12:30:40 +0000
+++ src/graphic/text/test/render_richtext.cc 2017-11-10 19:17:16 +0000
@@ -144,7 +144,7 @@
std::unique_ptr<Texture> texture(
new Texture(rendered_text->width(), rendered_text->height()));
std::unique_ptr<RenderTarget> dst(new RenderTarget(texture.get()));
- rendered_text->draw(*dst.get(), Vector2i::zero());
+ rendered_text->draw(*dst, Vector2i::zero());
std::unique_ptr<FileSystem> fs(&FileSystem::create("."));
std::unique_ptr<StreamWrite> sw(fs->open_stream_write(outname));
=== modified file 'src/io/filesystem/zip_filesystem.cc'
--- src/io/filesystem/zip_filesystem.cc 2017-01-25 18:55:59 +0000
+++ src/io/filesystem/zip_filesystem.cc 2017-11-10 19:17:16 +0000
@@ -498,10 +498,10 @@
size_t ZipFilesystem::ZipStreamRead::data(void* read_data, size_t bufsize) {
int copied = unzReadCurrentFile(zip_file_->read_handle(), read_data, bufsize);
if (copied < 0) {
- throw new DataError("Failed to read from zip file %s", zip_file_->path().c_str());
+ throw DataError("Failed to read from zip file %s", zip_file_->path().c_str());
}
if (copied == 0) {
- throw new DataError("End of file reaced while reading zip %s", zip_file_->path().c_str());
+ throw DataError("End of file reached while reading zip %s", zip_file_->path().c_str());
}
return copied;
}
=== modified file 'src/logic/editor_game_base.cc'
--- src/logic/editor_game_base.cc 2017-09-02 19:34:45 +0000
+++ src/logic/editor_game_base.cc 2017-11-10 19:17:16 +0000
@@ -73,7 +73,7 @@
}
EditorGameBase::~EditorGameBase() {
- delete player_manager_.release();
+ player_manager_.release();
}
void EditorGameBase::think() {
=== modified file 'src/logic/map_objects/immovable.cc'
--- src/logic/map_objects/immovable.cc 2017-08-19 22:22:20 +0000
+++ src/logic/map_objects/immovable.cc 2017-11-10 19:17:16 +0000
@@ -286,7 +286,7 @@
}
bool ImmovableDescr::has_terrain_affinity() const {
- return terrain_affinity_.get() != nullptr;
+ return terrain_affinity_ != nullptr;
}
const TerrainAffinity& ImmovableDescr::terrain_affinity() const {
=== modified file 'src/logic/map_objects/tribes/production_program.cc'
--- src/logic/map_objects/tribes/production_program.cc 2017-08-20 17:45:42 +0000
+++ src/logic/map_objects/tribes/production_program.cc 2017-11-10 19:17:16 +0000
@@ -1666,7 +1666,7 @@
arguments.get(), name().c_str(), building->name().c_str());
}
- const ProductionProgram::Action& action = *actions_.back().get();
+ const ProductionProgram::Action& action = *actions_.back();
for (const auto& group : action.consumed_wares_workers()) {
consumed_wares_workers_.push_back(group);
}
@@ -1703,7 +1703,7 @@
}
const ProductionProgram::Action& ProductionProgram::operator[](size_t const idx) const {
- return *actions_.at(idx).get();
+ return *actions_.at(idx);
}
const ProductionProgram::Groups& ProductionProgram::consumed_wares_workers() const {
=== modified file 'src/logic/map_objects/tribes/trainingsite.cc'
--- src/logic/map_objects/tribes/trainingsite.cc 2017-06-24 20:22:19 +0000
+++ src/logic/map_objects/tribes/trainingsite.cc 2017-11-10 19:17:16 +0000
@@ -75,7 +75,7 @@
train_health_ = true;
min_health_ = items_table->get_int("min_level");
max_health_ = items_table->get_int("max_level");
- add_training_inputs(*items_table.get(), &food_health_, &weapons_health_);
+ add_training_inputs(*items_table, &food_health_, &weapons_health_);
}
if (table.has_key("soldier attack")) {
@@ -83,21 +83,21 @@
train_attack_ = true;
min_attack_ = items_table->get_int("min_level");
max_attack_ = items_table->get_int("max_level");
- add_training_inputs(*items_table.get(), &food_attack_, &weapons_attack_);
+ add_training_inputs(*items_table, &food_attack_, &weapons_attack_);
}
if (table.has_key("soldier defense")) {
items_table = table.get_table("soldier defense");
train_defense_ = true;
min_defense_ = items_table->get_int("min_level");
max_defense_ = items_table->get_int("max_level");
- add_training_inputs(*items_table.get(), &food_defense_, &weapons_defense_);
+ add_training_inputs(*items_table, &food_defense_, &weapons_defense_);
}
if (table.has_key("soldier evade")) {
items_table = table.get_table("soldier evade");
train_evade_ = true;
min_evade_ = items_table->get_int("min_level");
max_evade_ = items_table->get_int("max_level");
- add_training_inputs(*items_table.get(), &food_evade_, &weapons_evade_);
+ add_training_inputs(*items_table, &food_evade_, &weapons_evade_);
}
}
=== modified file 'src/logic/map_objects/tribes/worker_descr.cc'
--- src/logic/map_objects/tribes/worker_descr.cc 2017-04-21 17:03:26 +0000
+++ src/logic/map_objects/tribes/worker_descr.cc 2017-11-10 19:17:16 +0000
@@ -107,7 +107,7 @@
programs_[program_name] = std::unique_ptr<WorkerProgram>(
new WorkerProgram(program_name, *this, egbase_.tribes()));
- programs_[program_name]->parse(*programs_table->get_table(program_name).get());
+ programs_[program_name]->parse(*programs_table->get_table(program_name));
} catch (const std::exception& e) {
throw wexception("program %s: %s", program_name.c_str(), e.what());
}
=== modified file 'src/network/gamehost.cc'
--- src/network/gamehost.cc 2017-11-06 20:19:56 +0000
+++ src/network/gamehost.cc 2017-11-10 19:17:16 +0000
@@ -1494,7 +1494,7 @@
// Scan-build reports that access to bytes here results in a dereference of null pointer.
// This is a false positive.
// See https://bugs.launchpad.net/widelands/+bug/1198919
- s.unsigned_32(file_->bytes);
+ s.unsigned_32(file_->bytes); // NOLINT
s.string(file_->md5sum);
return true;
}
=== modified file 'src/network/network_lan_promotion.cc'
--- src/network/network_lan_promotion.cc 2017-06-10 16:36:29 +0000
+++ src/network/network_lan_promotion.cc 2017-11-10 19:17:16 +0000
@@ -372,7 +372,7 @@
needupdate = true;
memset(&gameinfo, 0, sizeof(gameinfo));
- strcpy(gameinfo.magic, "GAME");
+ strncpy(gameinfo.magic, "GAME", sizeof(gameinfo.magic));
gameinfo.version = LAN_PROMOTION_PROTOCOL_VERSION;
gameinfo.state = LAN_GAME_OPEN;
=== modified file 'src/scripting/lua_map.cc'
--- src/scripting/lua_map.cc 2017-10-04 00:27:47 +0000
+++ src/scripting/lua_map.cc 2017-11-10 19:17:16 +0000
@@ -4114,7 +4114,7 @@
if (sp.second > 0) {
c_wares = count_wares_on_flag_(*f, tribes);
assert(c_wares.count(index) == 1);
- assert(c_wares[index] = sp.second);
+ assert(c_wares.at(index) == sp.second);
}
#endif
}
=== modified file 'src/third_party/eris/eris.c'
--- src/third_party/eris/eris.c 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/eris.c 2017-11-10 19:17:16 +0000
@@ -2363,7 +2363,7 @@
eris_checkstack(L, 1);
newbuff = (char*)lua_newuserdata(L, newcapacity * sizeof(char));
/* perms reftbl buff path? ... nbuff */
- memcpy(newbuff, eris_buffer(buff), eris_bufflen(buff));
+ memcpy(newbuff, eris_buffer(buff), eris_bufflen(buff)); // NOLINT
lua_replace(L, BUFFIDX); /* perms reftbl nbuff path? ... */
eris_buffer(buff) = newbuff;
eris_sizebuffer(buff) = newcapacity;
=== modified file 'src/third_party/eris/lauxlib.c'
--- src/third_party/eris/lauxlib.c 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/lauxlib.c 2017-11-10 19:17:16 +0000
@@ -502,7 +502,7 @@
newbuff = (char *)resizebox(L, -1, newsize);
else { /* no buffer yet */
newbuff = (char *)newbox(L, newsize);
- memcpy(newbuff, B->b, B->n * sizeof(char)); /* copy original content */
+ memcpy(newbuff, B->b, B->n * sizeof(char)); /* copy original content */ // NOLINT
}
B->b = newbuff;
B->size = newsize;
@@ -527,7 +527,7 @@
LUALIB_API void luaL_pushresult (luaL_Buffer *B) {
lua_State *L = B->L;
- lua_pushlstring(L, B->b, B->n);
+ lua_pushlstring(L, B->b, B->n); // NOLINT
if (buffonstack(B)) {
resizebox(L, -2, 0); /* delete old buffer */
lua_remove(L, -2); /* remove its header from the stack */
=== modified file 'src/third_party/eris/loslib.c'
--- src/third_party/eris/loslib.c 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/loslib.c 2017-11-10 19:17:16 +0000
@@ -271,7 +271,7 @@
luaL_error(L, "time result cannot be represented in this installation");
if (strcmp(s, "*t") == 0) {
lua_createtable(L, 0, 9); /* 9 = number of fields */
- setfield(L, "sec", stm->tm_sec);
+ setfield(L, "sec", stm->tm_sec); // NOLINT
setfield(L, "min", stm->tm_min);
setfield(L, "hour", stm->tm_hour);
setfield(L, "day", stm->tm_mday);
=== modified file 'src/third_party/eris/lstrlib.c'
--- src/third_party/eris/lstrlib.c 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/lstrlib.c 2017-11-10 19:17:16 +0000
@@ -975,7 +975,7 @@
size_t l = strlen(form);
size_t lm = strlen(lenmod);
char spec = form[l - 1];
- strcpy(form + l - 1, lenmod);
+ strcpy(form + l - 1, lenmod); // NOLINT
form[l + lm - 1] = spec;
form[l + lm] = '\0';
}
=== modified file 'src/third_party/eris/lua.c'
--- src/third_party/eris/lua.c 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/lua.c 2017-11-10 19:17:16 +0000
@@ -435,7 +435,7 @@
static int handle_script (lua_State *L, char **argv) {
int status;
const char *fname = argv[0];
- if (strcmp(fname, "-") == 0 && strcmp(argv[-1], "--") != 0)
+ if (strcmp(fname, "-") == 0 && strcmp(argv[-1], "--") != 0) // NOLINT
fname = NULL; /* stdin */
status = luaL_loadfile(L, fname);
if (status == LUA_OK) {
=== modified file 'src/third_party/eris/lvm.c'
--- src/third_party/eris/lvm.c 2016-04-23 08:57:47 +0000
+++ src/third_party/eris/lvm.c 2017-11-10 19:17:16 +0000
@@ -760,7 +760,7 @@
-void luaV_execute (lua_State *L) {
+void luaV_execute (lua_State *L) { // NOLINT
CallInfo *ci = L->ci;
LClosure *cl;
TValue *k;
=== modified file 'src/third_party/minizip/unzip.cc'
--- src/third_party/minizip/unzip.cc 2016-08-04 15:49:05 +0000
+++ src/third_party/minizip/unzip.cc 2017-11-10 19:17:16 +0000
@@ -143,7 +143,7 @@
unsigned char c;
const int32_t err = static_cast<int32_t>(ZREAD(*pzlib_filefunc_def, filestream, &c, 1));
if (err == 1) {
- *pi = static_cast<int32_t>(c);
+ *pi = static_cast<int32_t>(c); // NOLINT
return UNZ_OK;
} else
return ZERROR(*pzlib_filefunc_def, filestream) ? UNZ_ERRNO : UNZ_EOF;
@@ -254,7 +254,7 @@
break;
for (i = static_cast<int32_t>(uReadSize) - 3; i-- > 0;)
- if (*(buf + i) == 0x50 and *(buf + i + 1) == 0x4b and *(buf + i + 2) == 0x05 and
+ if (*(buf + i) == 0x50 and *(buf + i + 1) == 0x4b and *(buf + i + 2) == 0x05 and // NOLINT
*(buf + i + 3) == 0x06) {
uPosFound = uReadPos + i;
break;
@@ -545,9 +545,9 @@
if (file_info.size_file_comment > 0 && commentBufferSize > 0)
if (ZREAD(s->z_filefunc, s->filestream, szComment, uSizeRead) != uSizeRead)
err = UNZ_ERRNO;
- lSeek += file_info.size_file_comment - uSizeRead;
+ lSeek += file_info.size_file_comment - uSizeRead; // NOLINT
} else
- lSeek += file_info.size_file_comment;
+ lSeek += file_info.size_file_comment; // NOLINT
if (err == UNZ_OK && pfile_info)
*pfile_info = file_info;
@@ -783,7 +783,7 @@
if (s->cur_file_info.compression_method != 0 and
s->cur_file_info.compression_method != Z_DEFLATED)
- err = UNZ_BADZIPFILE;
+ err = UNZ_BADZIPFILE; // NOLINT
pfile_in_zip_read_info->crc32_wait = s->cur_file_info.crc;
pfile_in_zip_read_info->crc32 = 0;
@@ -1229,7 +1229,7 @@
unsigned char c;
const int32_t err = static_cast<int32_t>(ZREAD(*pzlib_filefunc_def, filestream, &c, 1));
if (err == 1) {
- *pi = static_cast<int32_t>(c);
+ *pi = static_cast<int32_t>(c); // NOLINT
return ZIP_OK;
} else
return ZERROR(*pzlib_filefunc_def, filestream) ? ZIP_ERRNO : ZIP_EOF;
@@ -1339,7 +1339,7 @@
break;
for (i = static_cast<int32_t>(uReadSize) - 3; i-- > 0;)
- if (*(buf + i) == 0x50 and *(buf + i + 1) == 0x4b and *(buf + i + 2) == 0x05 and
+ if (*(buf + i) == 0x50 and *(buf + i + 1) == 0x4b and *(buf + i + 2) == 0x05 and // NOLINT
*(buf + i + 3) == 0x06) {
uPosFound = uReadPos + i;
break;
@@ -1776,7 +1776,7 @@
uLong uTotalOutBefore;
if (zi->ci.stream.avail_out == 0) {
if (zipFlushWriteBuffer(zi) == ZIP_ERRNO)
- err = ZIP_ERRNO;
+ err = ZIP_ERRNO; // NOLINT
zi->ci.stream.avail_out = static_cast<uInt>(Z_BUFSIZE);
zi->ci.stream.next_out = zi->ci.buffered_data;
}
=== modified file 'src/ui_basic/window.cc'
--- src/ui_basic/window.cc 2017-09-11 19:18:49 +0000
+++ src/ui_basic/window.cc 2017-11-10 19:17:16 +0000
@@ -243,8 +243,8 @@
* Redraw the window frame
*/
void Window::draw_border(RenderTarget& dst) {
- assert(HZ_B_CORNER_PIXMAP_LEN >= VT_B_PIXMAP_THICKNESS);
- assert(HZ_B_MIDDLE_PIXMAP_LEN > 0);
+ static_assert(HZ_B_CORNER_PIXMAP_LEN >= VT_B_PIXMAP_THICKNESS, "HZ_B_CORNER_PIXMAP_LEN < VT_B_PIXMAP_THICKNESS");
+ static_assert(HZ_B_MIDDLE_PIXMAP_LEN > 0, "HZ_B_MIDDLE_PIXMAP_LEN <= 0");
const int32_t hz_bar_end = get_w() - HZ_B_CORNER_PIXMAP_LEN;
const int32_t hz_bar_end_minus_middle = hz_bar_end - HZ_B_MIDDLE_PIXMAP_LEN;
=== modified file 'src/wui/attack_box.cc'
--- src/wui/attack_box.cc 2017-08-19 22:22:20 +0000
+++ src/wui/attack_box.cc 2017-11-10 19:17:16 +0000
@@ -83,7 +83,7 @@
std::unique_ptr<UI::Button> button(new UI::Button(&parent, text, 8, 8, 26, 26,
g_gr->images().get("images/ui_basic/but2.png"),
text, tooltip_text));
- button.get()->sigclicked.connect(boost::bind(fn, boost::ref(*this)));
+ button->sigclicked.connect(boost::bind(fn, boost::ref(*this)));
parent.add(button.get());
return button;
}
=== modified file 'src/wui/chatoverlay.cc'
--- src/wui/chatoverlay.cc 2017-05-21 18:15:17 +0000
+++ src/wui/chatoverlay.cc 2017-11-10 19:17:16 +0000
@@ -175,7 +175,7 @@
// render everything in one single line.
im = UI::g_fh1->render(m->all_text_);
}
- assert(im.get() != nullptr);
+ assert(im != nullptr);
// Background
const int32_t height = im->height() > get_h() ? get_h() : im->height();
=== modified file 'src/wui/plot_area.cc'
--- src/wui/plot_area.cc 2017-05-31 21:27:07 +0000
+++ src/wui/plot_area.cc 2017-11-10 19:17:16 +0000
@@ -260,11 +260,13 @@
// The space at the end is intentional to have the tick centered
// over the number, not to the left
- std::shared_ptr<const UI::RenderedText> xtick = UI::g_fh1->render(
- xtick_text_style((boost::format("-%u ") % (max_x / how_many_ticks * i)).str()));
- Vector2i pos(posx, inner_h - kSpaceBottom + 10);
- UI::center_vertically(xtick->height(), &pos);
- xtick->draw(dst, pos, UI::Align::kCenter);
+ if (how_many_ticks != 0) {
+ std::shared_ptr<const UI::RenderedText> xtick = UI::g_fh1->render(
+ xtick_text_style((boost::format("-%u ") % (max_x / how_many_ticks * i)).str()));
+ Vector2i pos(posx, inner_h - kSpaceBottom + 10);
+ UI::center_vertically(xtick->height(), &pos);
+ xtick->draw(dst, pos, UI::Align::kCenter);
+ }
posx -= sub;
}
Follow ups
-
[Merge] lp:~widelands-dev/widelands/clang-tidy-round1 into lp:widelands
From: noreply, 2017-11-12
-
[Merge] lp:~widelands-dev/widelands/clang-tidy-round1 into lp:widelands
From: bunnybot, 2017-11-12
-
Re: [Merge] lp:~widelands-dev/widelands/clang-tidy-round1 into lp:widelands
From: GunChleoc, 2017-11-12
-
[Merge] lp:~widelands-dev/widelands/clang-tidy-round1 into lp:widelands
From: bunnybot, 2017-11-12
-
Re: [Merge] lp:~widelands-dev/widelands/clang-tidy-round1 into lp:widelands
From: GunChleoc, 2017-11-12
-
[Merge] lp:~widelands-dev/widelands/clang-tidy-round1 into lp:widelands
From: bunnybot, 2017-11-12
-
[Merge] lp:~widelands-dev/widelands/clang-tidy-round1 into lp:widelands
From: bunnybot, 2017-11-12
-
Re: [Merge] lp:~widelands-dev/widelands/clang-tidy-round1 into lp:widelands
From: GunChleoc, 2017-11-11
-
[Merge] lp:~widelands-dev/widelands/clang-tidy-round1 into lp:widelands
From: bunnybot, 2017-11-11
-
Re: [Merge] lp:~widelands-dev/widelands/clang-tidy-round1 into lp:widelands
From: SirVer, 2017-11-10