Fixing some minor lint, found by Pavel Shlyak using PVS studio

This commit is contained in:
Matthias Melcher
2018-12-27 13:05:35 +01:00
parent 5c7118f8d9
commit 75eefbcd42
8 changed files with 39 additions and 45 deletions
-8
View File
@@ -337,7 +337,6 @@ void Fl_Table_Type::move_child(Fl_Type* cc, Fl_Type* before) {
Fl_Widget *Fl_Group_Type::enter_live_mode(int) { Fl_Widget *Fl_Group_Type::enter_live_mode(int) {
Fl_Group *grp = new Fl_Group(o->x(), o->y(), o->w(), o->h()); Fl_Group *grp = new Fl_Group(o->x(), o->y(), o->w(), o->h());
live_widget = grp; live_widget = grp;
if (live_widget) {
copy_properties(); copy_properties();
Fl_Type *n; Fl_Type *n;
for (n = next; n && n->level > level; n = n->next) { for (n = next; n && n->level > level; n = n->next) {
@@ -345,14 +344,12 @@ Fl_Widget *Fl_Group_Type::enter_live_mode(int) {
n->enter_live_mode(); n->enter_live_mode();
} }
grp->end(); grp->end();
}
return live_widget; return live_widget;
} }
Fl_Widget *Fl_Tabs_Type::enter_live_mode(int) { Fl_Widget *Fl_Tabs_Type::enter_live_mode(int) {
Fl_Tabs *grp = new Fl_Tabs(o->x(), o->y(), o->w(), o->h()); Fl_Tabs *grp = new Fl_Tabs(o->x(), o->y(), o->w(), o->h());
live_widget = grp; live_widget = grp;
if (live_widget) {
copy_properties(); copy_properties();
Fl_Type *n; Fl_Type *n;
for (n = next; n && n->level > level; n = n->next) { for (n = next; n && n->level > level; n = n->next) {
@@ -360,7 +357,6 @@ Fl_Widget *Fl_Tabs_Type::enter_live_mode(int) {
n->enter_live_mode(); n->enter_live_mode();
} }
grp->end(); grp->end();
}
grp->value(((Fl_Tabs*)o)->value()); grp->value(((Fl_Tabs*)o)->value());
return live_widget; return live_widget;
} }
@@ -368,10 +364,8 @@ Fl_Widget *Fl_Tabs_Type::enter_live_mode(int) {
Fl_Widget *Fl_Table_Type::enter_live_mode(int) { Fl_Widget *Fl_Table_Type::enter_live_mode(int) {
Fl_Group *grp = new Fluid_Table(o->x(), o->y(), o->w(), o->h()); Fl_Group *grp = new Fluid_Table(o->x(), o->y(), o->w(), o->h());
live_widget = grp; live_widget = grp;
if (live_widget) {
copy_properties(); copy_properties();
grp->end(); grp->end();
}
return live_widget; return live_widget;
} }
@@ -396,7 +390,6 @@ Fl_Widget *Fl_Scroll_Type::enter_live_mode(int) {
Fl_Group *grp = new Fl_Scroll(o->x(), o->y(), o->w(), o->h()); Fl_Group *grp = new Fl_Scroll(o->x(), o->y(), o->w(), o->h());
grp->show(); grp->show();
live_widget = grp; live_widget = grp;
if (live_widget) {
copy_properties(); copy_properties();
Fl_Type *n; Fl_Type *n;
for (n = next; n && n->level > level; n = n->next) { for (n = next; n && n->level > level; n = n->next) {
@@ -404,7 +397,6 @@ Fl_Widget *Fl_Scroll_Type::enter_live_mode(int) {
n->enter_live_mode(); n->enter_live_mode();
} }
grp->end(); grp->end();
}
return live_widget; return live_widget;
} }
+8 -8
View File
@@ -360,27 +360,27 @@ void Fl_Menu_Item_Type::write_code1() {
} }
} }
int init = 0; int menuItemInitialized = 0;
// if the name is an array variable, assign the value here // if the name is an array variable, assign the value here
if (name() && strchr(name(), '[')) { if (name() && strchr(name(), '[')) {
write_c("%s%s = &%s[%d];\n", indent(), name(), mname, i); write_c("%s%s = &%s[%d];\n", indent(), name(), mname, i);
} }
if (image) { if (image) {
if (!init) { menuItemInitialized = 1;
init = 1;
write_c("%s{ Fl_Menu_Item* o = &%s[%d];\n", indent(), mname, i); write_c("%s{ Fl_Menu_Item* o = &%s[%d];\n", indent(), mname, i);
}
image->write_code("o"); image->write_code("o");
} }
for (int n=0; n < NUM_EXTRA_CODE; n++) for (int n=0; n < NUM_EXTRA_CODE; n++) {
if (extra_code(n) && !isdeclare(extra_code(n))) { if (extra_code(n) && !isdeclare(extra_code(n))) {
if (!init) { if (!menuItemInitialized) {
init = 1; menuItemInitialized = 1;
write_c("%s{ Fl_Menu_Item* o = &%s[%d];\n", indent(), mname, i); write_c("%s{ Fl_Menu_Item* o = &%s[%d];\n", indent(), mname, i);
} }
write_c("%s %s\n", indent(), extra_code(n)); write_c("%s %s\n", indent(), extra_code(n));
} }
if (init) write_c("%s}\n",indent()); }
if (menuItemInitialized)
write_c("%s}\n",indent());
} }
void Fl_Menu_Item_Type::write_code2() {} void Fl_Menu_Item_Type::write_code2() {}
+1
View File
@@ -1306,6 +1306,7 @@ int Fl::handle_(int e, Fl_Window* window)
case FL_UNFOCUS: case FL_UNFOCUS:
window = 0; window = 0;
// FALLTHROUGH
case FL_FOCUS: case FL_FOCUS:
fl_xfocus = window; fl_xfocus = window;
fl_fix_focus(); fl_fix_focus();
+3 -3
View File
@@ -511,7 +511,7 @@ void Fl_Browser::item_draw(void* item, int X, int Y, int W, int H) const {
char* str = l->txt; char* str = l->txt;
const int* i = column_widths(); const int* i = column_widths();
bool first = true; // for icon bool firstLoop = true; // for icon
while (W > 6) { // do each tab-separated field while (W > 6) { // do each tab-separated field
int w1 = W; // width for this field int w1 = W; // width for this field
char* e = 0; // pointer to end of field or null if none char* e = 0; // pointer to end of field or null if none
@@ -520,8 +520,8 @@ void Fl_Browser::item_draw(void* item, int X, int Y, int W, int H) const {
if (e) {*e = 0; w1 = *i++;} if (e) {*e = 0; w1 = *i++;}
} }
// Icon drawing code // Icon drawing code
if (first) { if (firstLoop) {
first = false; firstLoop = false;
if (l->icon) { if (l->icon) {
l->icon->draw(X+2,Y+1); // leave 2px left, 1px above l->icon->draw(X+2,Y+1); // leave 2px left, 1px above
int iconw = l->icon->w()+2; int iconw = l->icon->w()+2;
+1 -1
View File
@@ -433,6 +433,7 @@ void
Fl_File_Chooser::directory(const char *d)// I - Directory to change to Fl_File_Chooser::directory(const char *d)// I - Directory to change to
{ {
char *dirptr; // Pointer into directory char *dirptr; // Pointer into directory
char fixpath[FL_PATH_MAX]; // Path with slashes converted
// printf("Fl_File_Chooser::directory(\"%s\")\n", d == NULL ? "(null)" : d); // printf("Fl_File_Chooser::directory(\"%s\")\n", d == NULL ? "(null)" : d);
@@ -444,7 +445,6 @@ Fl_File_Chooser::directory(const char *d)// I - Directory to change to
if (Fl::system_driver()->backslash_as_slash()) { if (Fl::system_driver()->backslash_as_slash()) {
// See if the filename contains backslashes... // See if the filename contains backslashes...
char *slash; // Pointer to slashes char *slash; // Pointer to slashes
char fixpath[FL_PATH_MAX]; // Path with slashes converted
if (strchr(d, '\\')) { if (strchr(d, '\\')) {
// Convert backslashes to slashes... // Convert backslashes to slashes...
strlcpy(fixpath, d, sizeof(fixpath)); strlcpy(fixpath, d, sizeof(fixpath));
+1
View File
@@ -1010,6 +1010,7 @@ int Fl_Input_::handletext(int event, int X, int Y, int W, int H) {
if (!(damage()&FL_DAMAGE_EXPOSE)) {minimal_update(position_); erase_cursor_only = 1;} if (!(damage()&FL_DAMAGE_EXPOSE)) {minimal_update(position_); erase_cursor_only = 1;}
} else //if (Fl::selection_owner() != this) } else //if (Fl::selection_owner() != this)
minimal_update(mark_, position_); minimal_update(mark_, position_);
// FALLTHROUGH
case FL_HIDE: case FL_HIDE:
fl_reset_spot(); fl_reset_spot();
if (!readonly() && (when() & FL_WHEN_RELEASE)) if (!readonly() && (when() & FL_WHEN_RELEASE))
+1 -1
View File
@@ -533,7 +533,7 @@ int menuwindow::find_selected(int mx, int my) {
if (my < 0 || my >= h()) return -1; if (my < 0 || my >= h()) return -1;
if (!itemheight) { // menubar if (!itemheight) { // menubar
int xx = 3; int n = 0; int xx = 3; int n = 0;
const Fl_Menu_Item* m = menu ? menu->first() : 0; const Fl_Menu_Item* m = menu->first();
for (; ; m = m->next(), n++) { for (; ; m = m->next(), n++) {
if (!m->text) return -1; if (!m->text) return -1;
xx += m->measure(0, button) + 16; xx += m->measure(0, button) + 16;
+1 -1
View File
@@ -1248,7 +1248,7 @@ void Fl_Text_Buffer::remove_(int start, int end)
/* expand the gap to encompass the deleted characters */ /* expand the gap to encompass the deleted characters */
mGapEnd += end - mGapStart; mGapEnd += end - mGapStart;
mGapStart -= mGapStart - start; mGapStart = start;
/* update the length */ /* update the length */
mLength -= end - start; mLength -= end - start;