From: Gabe Black Date: Thu, 5 Oct 2017 02:19:22 +0000 (-0700) Subject: misc: Fix the indentation in DecodeVarint in util/protolib.py. X-Git-Tag: v19.0.0.0~2611 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2243430eac4f6049d2f943627ad993e74eca31eb;p=gem5.git misc: Fix the indentation in DecodeVarint in util/protolib.py. The DecodeVarint was, as a comment describes, lifted from google.protobuf.internal.decoder. Unfortunately, the relative indentation of some lines was changed, changing what scope they fell under. This changed the behavior of the function, breaking it for multibyte and negative values. This change restores the correct indentation and fixes the function's behavior. Change-Id: If645649506b0fe5a617b37a8202c9ca1c57aaf15 Reviewed-on: https://gem5-review.googlesource.com/5000 Reviewed-by: Andreas Sandberg Maintainer: Andreas Sandberg --- diff --git a/util/protolib.py b/util/protolib.py index 47ac8768f..c8c6d0c49 100644 --- a/util/protolib.py +++ b/util/protolib.py @@ -123,10 +123,10 @@ def DecodeVarint(in_file): result |= ~mask else: result &= mask - return (result, pos) - shift += 7 - if shift >= 64: - raise IOError('Too many bytes when decoding varint.') + return (result, pos) + shift += 7 + if shift >= 64: + raise IOError('Too many bytes when decoding varint.') def decodeMessage(in_file, message): """