Fixing the compiler error on gcc, error: control reaches end of non-void function [-Werror=return-type] Test: atest libavb_host_unittest libavb_host_unittest_sha Bug: 351985950 Change-Id: Ie6a44cb41f52ade3a0083698188d9360944a0a5c
diff --git a/libavb/avb_cmdline.c b/libavb/avb_cmdline.c index 28f948f..b6793c1 100644 --- a/libavb/avb_cmdline.c +++ b/libavb/avb_cmdline.c
@@ -208,13 +208,23 @@ } static const char* cmdline_get_digest_name(AvbDigestType avb_digest_type) { + const char* ret = NULL; switch (avb_digest_type) { case AVB_DIGEST_TYPE_SHA256: - return "sha256"; + ret = "sha256"; + break; case AVB_DIGEST_TYPE_SHA512: - return "sha512"; + ret = "sha512"; + break; /* Do not add a 'default:' case here because of -Wswitch. */ } + + if (ret == NULL) { + avb_error("Unknown AvbDigestType.\n"); + ret = "unknown"; + } + + return ret; } AvbSlotVerifyResult avb_append_options(