From 64abf60ae196bd3ad59531f48d2e2c78efa5987c Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 6 May 2019 17:40:51 +0200 Subject: Avoid warning on taking length of undefined list Recently added check for fatuous sanity review tested for empty comments with int($$verdict{comments}) == 0 but it's possible that $$verdict{comments} is undefined; when it is, we get a warning here: Use of uninitialized value in int at /srv/gerrit/sanitybot/gerrit-bot.pl line 224. So add and tweak some punctuation to make perl happy again. Thanks to Ossi for the appropriate runes. Change-Id: I211baa2e61cda98fc61ec97775f5a247da00c1f4 Reviewed-by: Oswald Buddenhagen Reviewed-by: Orgad Shaneh --- git-hooks/gerrit-bot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-hooks/gerrit-bot b/git-hooks/gerrit-bot index 29ad4ed..4bd24b7 100755 --- a/git-hooks/gerrit-bot +++ b/git-hooks/gerrit-bot @@ -221,7 +221,7 @@ sub process_commit($$$$$) merge_hashes($verdict, $vd); } } - if ($$verdict{labels}{'Sanity-Review'} == 1 && int($$verdict{comments}) == 0) { + if ($$verdict{labels}{'Sanity-Review'} == 1 && int(@{$verdict{comments} || []}) == 0) { # Don't spam everyone about a boring +1 sanity review with no comments. $$verdict{notify} = "NONE"; } -- cgit v1.2.3