From d05a36676f095892dd2c9010c44ee42ebe232915 Mon Sep 17 00:00:00 2001 From: Jude Melton-Houghton Date: Fri, 30 Jul 2021 13:19:56 -0400 Subject: [PATCH] Make get_bit simpler again --- mesecons/util.lua | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mesecons/util.lua b/mesecons/util.lua index 846c995..234775b 100644 --- a/mesecons/util.lua +++ b/mesecons/util.lua @@ -163,12 +163,9 @@ function mesecon.getbinstate(nodename, states) end function mesecon.get_bit(binary,bit) + bit = bit or 1 local len = binary:len() - if bit then - if bit > len then return false end - else - bit = 1 - end + if bit > len then return false end local c = len-(bit-1) return binary:sub(c,c) == "1" end