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

View File

@ -337,30 +337,26 @@ void Fl_Table_Type::move_child(Fl_Type* cc, Fl_Type* before) {
Fl_Widget *Fl_Group_Type::enter_live_mode(int) {
Fl_Group *grp = new Fl_Group(o->x(), o->y(), o->w(), o->h());
live_widget = grp;
if (live_widget) {
copy_properties();
Fl_Type *n;
for (n = next; n && n->level > level; n = n->next) {
if (n->level == level+1)
n->enter_live_mode();
}
grp->end();
copy_properties();
Fl_Type *n;
for (n = next; n && n->level > level; n = n->next) {
if (n->level == level+1)
n->enter_live_mode();
}
grp->end();
return live_widget;
}
Fl_Widget *Fl_Tabs_Type::enter_live_mode(int) {
Fl_Tabs *grp = new Fl_Tabs(o->x(), o->y(), o->w(), o->h());
live_widget = grp;
if (live_widget) {
copy_properties();
Fl_Type *n;
for (n = next; n && n->level > level; n = n->next) {
if (n->level == level+1)
n->enter_live_mode();
}
grp->end();
copy_properties();
Fl_Type *n;
for (n = next; n && n->level > level; n = n->next) {
if (n->level == level+1)
n->enter_live_mode();
}
grp->end();
grp->value(((Fl_Tabs*)o)->value());
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_Group *grp = new Fluid_Table(o->x(), o->y(), o->w(), o->h());
live_widget = grp;
if (live_widget) {
copy_properties();
grp->end();
}
copy_properties();
grp->end();
return live_widget;
}
@ -396,15 +390,13 @@ Fl_Widget *Fl_Scroll_Type::enter_live_mode(int) {
Fl_Group *grp = new Fl_Scroll(o->x(), o->y(), o->w(), o->h());
grp->show();
live_widget = grp;
if (live_widget) {
copy_properties();
Fl_Type *n;
for (n = next; n && n->level > level; n = n->next) {
if (n->level == level+1)
n->enter_live_mode();
}
grp->end();
copy_properties();
Fl_Type *n;
for (n = next; n && n->level > level; n = n->next) {
if (n->level == level+1)
n->enter_live_mode();
}
grp->end();
return live_widget;
}

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 (name() && strchr(name(), '[')) {
write_c("%s%s = &%s[%d];\n", indent(), name(), mname, i);
}
if (image) {
if (!init) {
init = 1;
write_c("%s{ Fl_Menu_Item* o = &%s[%d];\n", indent(), mname, i);
}
menuItemInitialized = 1;
write_c("%s{ Fl_Menu_Item* o = &%s[%d];\n", indent(), mname, i);
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 (!init) {
init = 1;
write_c("%s{ Fl_Menu_Item* o = &%s[%d];\n", indent(), mname, i);
if (!menuItemInitialized) {
menuItemInitialized = 1;
write_c("%s{ Fl_Menu_Item* o = &%s[%d];\n", indent(), mname, i);
}
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() {}

View File

@ -1306,6 +1306,7 @@ int Fl::handle_(int e, Fl_Window* window)
case FL_UNFOCUS:
window = 0;
// FALLTHROUGH
case FL_FOCUS:
fl_xfocus = window;
fl_fix_focus();

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;
const int* i = column_widths();
bool first = true; // for icon
bool firstLoop = true; // for icon
while (W > 6) { // do each tab-separated field
int w1 = W; // width for this field
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++;}
}
// Icon drawing code
if (first) {
first = false;
if (firstLoop) {
firstLoop = false;
if (l->icon) {
l->icon->draw(X+2,Y+1); // leave 2px left, 1px above
int iconw = l->icon->w()+2;

View File

@ -432,7 +432,8 @@ Fl_File_Chooser::count() {
void
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);
@ -444,7 +445,6 @@ Fl_File_Chooser::directory(const char *d)// I - Directory to change to
if (Fl::system_driver()->backslash_as_slash()) {
// See if the filename contains backslashes...
char *slash; // Pointer to slashes
char fixpath[FL_PATH_MAX]; // Path with slashes converted
if (strchr(d, '\\')) {
// Convert backslashes to slashes...
strlcpy(fixpath, d, sizeof(fixpath));

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;}
} else //if (Fl::selection_owner() != this)
minimal_update(mark_, position_);
// FALLTHROUGH
case FL_HIDE:
fl_reset_spot();
if (!readonly() && (when() & FL_WHEN_RELEASE))

View File

@ -533,7 +533,7 @@ int menuwindow::find_selected(int mx, int my) {
if (my < 0 || my >= h()) return -1;
if (!itemheight) { // menubar
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++) {
if (!m->text) return -1;
xx += m->measure(0, button) + 16;

View File

@ -1248,7 +1248,7 @@ void Fl_Text_Buffer::remove_(int start, int end)
/* expand the gap to encompass the deleted characters */
mGapEnd += end - mGapStart;
mGapStart -= mGapStart - start;
mGapStart = start;
/* update the length */
mLength -= end - start;