From 47ec81408e6272e3baeceace27b94195c21e06b6 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Mon, 17 Jun 2024 09:13:16 +0300 Subject: [PATCH] scripts/device: avoid crashing if the device.name is not set This should never happen, but there are odd cases with broken configuration where such a device may appear and the least we can do is not crash, at least not when the device.name is only used for debug messages. In state-profile and other places where the name really matters, we actually have checks in place. Fixes: #674 --- src/scripts/device/apply-profile.lua | 2 +- src/scripts/device/find-best-profile.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scripts/device/apply-profile.lua b/src/scripts/device/apply-profile.lua index bd09974e..0956ef47 100644 --- a/src/scripts/device/apply-profile.lua +++ b/src/scripts/device/apply-profile.lua @@ -23,7 +23,7 @@ AsyncEventHook { execute = function (event, transition) local device = event:get_subject () local profile = event:get_data ("selected-profile") - local dev_name = device.properties ["device.name"] + local dev_name = device.properties ["device.name"] or "" if not profile then log:info (device, "No profile found to set on " .. dev_name) diff --git a/src/scripts/device/find-best-profile.lua b/src/scripts/device/find-best-profile.lua index 368ea3a5..a9e40c7e 100644 --- a/src/scripts/device/find-best-profile.lua +++ b/src/scripts/device/find-best-profile.lua @@ -28,7 +28,7 @@ SimpleEventHook { end local device = event:get_subject () - local dev_name = device.properties["device.name"] + local dev_name = device.properties["device.name"] or "" local off_profile = nil local best_profile = nil local unk_profile = nil