From 902751a19e34817725b056c401ee28b343a22c52 Mon Sep 17 00:00:00 2001 From: Attie Grande Date: Mon, 15 Jan 2024 14:50:53 +0000 Subject: [PATCH] cmake: hex: fix conversion of zero to hex Previously, `to_hex(0 output)` would have placed `0x` into the `output` variable, which is undesirable... this fix ensures that `0x0` is placed into this variable if the input is zero. Signed-off-by: Attie Grande --- cmake/hex.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/hex.cmake b/cmake/hex.cmake index 5823dc9109..c3935f613f 100644 --- a/cmake/hex.cmake +++ b/cmake/hex.cmake @@ -34,6 +34,10 @@ function(from_hex HEX DEC) endfunction() function(to_hex DEC HEX) + if(DEC EQUAL 0) + set(${HEX} "0x0" PARENT_SCOPE) + return() + endif() while(DEC GREATER 0) math(EXPR _val "${DEC} % 16") math(EXPR DEC "${DEC} / 16")