From 7492df0d1b7ae0bcf32f69e85343a0b2432bc40a Mon Sep 17 00:00:00 2001 From: sirlilpanda <33928689+sirlilpanda@users.noreply.github.com> Date: Mon, 1 Sep 2025 23:23:37 +1200 Subject: [PATCH] added some comments and removed the pointer back to device since it was unused --- src/states/debug_state.c | 2 +- src/states/lock_state.c | 2 +- src/states/off_state.c | 4 +++- src/states/unlock_state.c | 5 +++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/states/debug_state.c b/src/states/debug_state.c index 07c23e8..47d8276 100644 --- a/src/states/debug_state.c +++ b/src/states/debug_state.c @@ -3,6 +3,7 @@ #include "state.h" #include "../device.h" +// this is me being lazy const char debug_state_name[] = __FILE_NAME__; static void pressPwrMethod(Device_t *device) { @@ -23,7 +24,6 @@ static void pressLockMethod(Device_t *device) { void setDeviceStateToDebug(Device_t *device) { device->state = (DeviceState_t){ .state_name = debug_state_name, - .device = device, .methods = (DeviceInterface_t){ .pressPwr = &pressPwrMethod, .pressStrInput = &pressStrInputMethod, diff --git a/src/states/lock_state.c b/src/states/lock_state.c index 245647d..c18c88e 100644 --- a/src/states/lock_state.c +++ b/src/states/lock_state.c @@ -4,6 +4,7 @@ #include "state.h" #include "../device.h" +// this is me being lazy const char lock_state_name[] = __FILE_NAME__; static void pressPwrMethod(Device_t *device) { @@ -35,7 +36,6 @@ static void pressLockMethod(Device_t *device) { void setDeviceStateToLock(Device_t *device) { device->state = (DeviceState_t){ .state_name = lock_state_name, - .device = device, .methods = (DeviceInterface_t){ .pressPwr = &pressPwrMethod, .pressStrInput = &pressStrInputMethod, diff --git a/src/states/off_state.c b/src/states/off_state.c index 8d3e74f..8c05511 100644 --- a/src/states/off_state.c +++ b/src/states/off_state.c @@ -2,6 +2,7 @@ #include "../device.h" #include +// this is me being lazy const char off_state_name[] = __FILE_NAME__; static void pressPwrMethod(Device_t *device) { @@ -10,11 +11,13 @@ static void pressPwrMethod(Device_t *device) { } static void pressStrInputMethod(Device_t *device) { + // cast it to void since its unused (void) device; printf("nothing happens\n"); } static void pressLockMethod(Device_t *device) { + // cast it to void since its unused (void) device; printf("nothing happens\n"); } @@ -22,7 +25,6 @@ static void pressLockMethod(Device_t *device) { void setDeviceStateToOff(Device_t *device) { device->state = (DeviceState_t){ .state_name = off_state_name, - .device = device, .methods = (DeviceInterface_t){ .pressPwr = &pressPwrMethod, .pressStrInput = &pressStrInputMethod, diff --git a/src/states/unlock_state.c b/src/states/unlock_state.c index b3abb44..5c51c69 100644 --- a/src/states/unlock_state.c +++ b/src/states/unlock_state.c @@ -13,6 +13,8 @@ static void pressPwrMethod(Device_t *device) { } static void pressStrInputMethod(Device_t *device) { + + // check to see if the entered string is the one to enter the debug state if (strcmp(device->entered_string, "dbg") == 0) { printf("entering debug state\n"); setDeviceStateToDebug(device); @@ -27,9 +29,8 @@ static void pressLockMethod(Device_t *device) { } void setDeviceStateToUnlock(Device_t *device) { - device->state = (DeviceState_t){ + device->state = (DeviceState_t) { .state_name = name, - .device = device, .methods = (DeviceInterface_t){ .pressPwr = &pressPwrMethod, .pressStrInput = &pressStrInputMethod,