aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremias Stotter <jeremias@stotter.eu>2023-10-15 21:13:01 +0200
committerJeremias Stotter <jeremias@stotter.eu>2023-10-15 21:13:01 +0200
commit3ceded204ece41bd3599e5da2369d7e6795bd159 (patch)
treee39631492a1dc710617872fad4c21faa6e596cc6
parenta8fe00b137dc473e7a707123828deaafc92b5e59 (diff)
downloadnetwork-simulator-3ceded204ece41bd3599e5da2369d7e6795bd159.tar.gz
network-simulator-3ceded204ece41bd3599e5da2369d7e6795bd159.tar.bz2
network-simulator-3ceded204ece41bd3599e5da2369d7e6795bd159.zip
Some cleanups
-rw-r--r--gui.c9
-rw-r--r--gui_device.c1
-rw-r--r--lua_functions.c12
-rw-r--r--undo-redo.c2
4 files changed, 9 insertions, 15 deletions
diff --git a/gui.c b/gui.c
index da7dda3..f1a9ff0 100644
--- a/gui.c
+++ b/gui.c
@@ -995,6 +995,7 @@ void drawing_area_release(GtkGestureClick* self, gint n_press, gdouble x, gdoubl
// Offset between start click and now
int xoff = x - xstart;
int yoff = y - ystart;
+ struct undo_entry* undo_new = NULL;
// Click not drag
switch(area_mode) {
case MODE_MOVE:
@@ -1035,7 +1036,6 @@ void drawing_area_release(GtkGestureClick* self, gint n_press, gdouble x, gdoubl
created_device->X = x - (created_device->template->icon_size >> 2);
created_device->Y = y - (created_device->template->icon_size >> 2);
// Add the action to the list
- struct undo_entry* undo_new;
struct undo_add_dev_data* undo_add_new;
NEW_UNDO_STRUCT(undo_add_dev, undo_add_dev_data, undo_new, undo_add_new);
undo_add_new->dev = created_device;
@@ -1052,7 +1052,6 @@ void drawing_area_release(GtkGestureClick* self, gint n_press, gdouble x, gdoubl
new_deco->Y = y;
gui_change_deco_text(new_deco);
- struct undo_entry* undo_new = NULL;
struct undo_add_deco_data* undo_add_deco_data_new = NULL;
NEW_UNDO_STRUCT(undo_add_deco, undo_add_deco_data, undo_new, undo_add_deco_data_new);
undo_add_deco_data_new->deco = new_deco;
@@ -1070,7 +1069,6 @@ void drawing_area_release(GtkGestureClick* self, gint n_press, gdouble x, gdoubl
if(del_device) {
// Use free device later once this action is removed from the undo stack
// Add the action to the list
- struct undo_entry* undo_new;
struct undo_del_dev_data* undo_del_new;
NEW_UNDO_STRUCT(undo_del_dev, undo_del_dev_data, undo_new, undo_del_new);
undo_del_new->dev = del_device->selected_device;
@@ -1082,7 +1080,6 @@ void drawing_area_release(GtkGestureClick* self, gint n_press, gdouble x, gdoubl
}
struct connection* delete_con = get_connection_at(x-2,y-2,x+2,y+2);
if(delete_con) {
- struct undo_entry* undo_new = NULL;
struct undo_del_con_data* undo_del_con_new = NULL;
NEW_UNDO_STRUCT(undo_del_con, undo_del_con_data, undo_new, undo_del_con_new);
@@ -1095,7 +1092,6 @@ void drawing_area_release(GtkGestureClick* self, gint n_press, gdouble x, gdoubl
}
struct deco* delete_text = get_deco_at(x,y,x,y);
if(delete_text) {
- struct undo_entry* undo_new = NULL;
struct undo_del_deco_data* undo_del_deco_data_new = NULL;
NEW_UNDO_STRUCT(undo_del_deco, undo_del_deco_data, undo_new, undo_del_deco_data_new);
undo_del_deco_data_new->deco = delete_text;
@@ -1280,7 +1276,6 @@ void drawing_area_motion(GtkEventControllerKey* self, gdouble x, gdouble y, gpoi
int gui_send_info(struct interface* send_interface, const char* send_data, int data_len, const char* type) {
if(!fastmode) {
if(!send_interface || !send_interface->connection) return -1;
- struct connection* con = send_interface->connection;
/*GtkTreeIter packet_iter;
gtk_list_store_append(packet_list, &packet_iter);
@@ -1301,7 +1296,7 @@ int gui_send_info(struct interface* send_interface, const char* send_data, int d
int index = *(gtk_tree_path_get_indices(new_path));*/
GObject* data_object = g_object_new(G_TYPE_OBJECT, NULL);
- g_object_set_data(data_object, "Status", con ? "Buffered" : "Disconected");
+ g_object_set_data(data_object, "Status", "Buffered");
g_object_set_data(data_object, "Device1", send_interface->parent_device->name);
g_object_set_data(data_object, "Device2", send_interface == send_interface->connection->interface1 ?
send_interface->connection->interface2->parent_device->name :
diff --git a/gui_device.c b/gui_device.c
index be53108..18a18fd 100644
--- a/gui_device.c
+++ b/gui_device.c
@@ -100,7 +100,6 @@ bool entry_key_pressed(GtkEventControllerKey* self,
dev->cmdline_current_index--;
}
return true;
- break;
}
break;
}
diff --git a/lua_functions.c b/lua_functions.c
index e2bedd7..fdf99c6 100644
--- a/lua_functions.c
+++ b/lua_functions.c
@@ -138,17 +138,17 @@ json_object* table_to_json(lua_State* lua_vm, int index) {
lua_pushnil(lua_vm);
char numeric_index[25] = "";
while(lua_next(lua_vm, index)) {
- const char* index = NULL;
+ const char* t_index = NULL;
int need_free = 0;
switch(lua_type(lua_vm, -2)) {
// keys will either start with an s for string, an i for integer or a f for float
case LUA_TNUMBER:
if(lua_isinteger(lua_vm, -2)) {
snprintf(numeric_index, 20, "i%lld", lua_tointeger(lua_vm, -2));
- index = numeric_index;
+ t_index = numeric_index;
} else {
snprintf(numeric_index, 20, "f%lf", lua_tonumber(lua_vm, -2));
- index = numeric_index;
+ t_index = numeric_index;
}
break;
case LUA_TSTRING:
@@ -156,7 +156,7 @@ json_object* table_to_json(lua_State* lua_vm, int index) {
size_t lua_index_s;
const char* lua_index = lua_tolstring(lua_vm, -2, &lua_index_s);
// Replace any instances of "\0" with "%0" because json_c needs it
- index = string_to_numeric(lua_index, lua_index_s);
+ t_index = string_to_numeric(lua_index, lua_index_s);
need_free = 1;
}
break;
@@ -188,9 +188,9 @@ json_object* table_to_json(lua_State* lua_vm, int index) {
break;
}
- json_object_object_add_ex(return_obj, index, subobj, JSON_C_TO_STRING_NOSLASHESCAPE);
+ json_object_object_add_ex(return_obj, t_index, subobj, JSON_C_TO_STRING_NOSLASHESCAPE);
lua_pop(lua_vm, 1);
- if(need_free) free((char*)index);
+ if(need_free) free((char*)t_index);
}
// Return the stack to its former state
lua_settop(lua_vm, start_top);
diff --git a/undo-redo.c b/undo-redo.c
index 02a14d0..ba0444a 100644
--- a/undo-redo.c
+++ b/undo-redo.c
@@ -211,7 +211,7 @@ int redo() {
if(!cur_entry || !cur_entry->next) return 0;
cur_entry = cur_entry->next;
// Start from the back
- struct undo_entry* rentry;
+ struct undo_entry* rentry = NULL;
for(struct undo_entry* test_entry = cur_entry; test_entry; test_entry = test_entry->next_sibling) {
rentry = test_entry;
}
Jeremias Stotters git repositories generated by CGIT