From patchwork Thu Jan 28 11:28:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suraev X-Patchwork-Id: 574666 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by ozlabs.org (Postfix) with ESMTP id 5629D140BA0 for ; Thu, 28 Jan 2016 22:28:45 +1100 (AEDT) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id B3C5BB9BF; Thu, 28 Jan 2016 11:28:43 +0000 (UTC) X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received: from hylle06.itea.ntnu.no (hylle06.itea.ntnu.no [129.241.56.235]) by lists.osmocom.org (Postfix) with ESMTP id 0DDAEB9A3 for ; Thu, 28 Jan 2016 11:28:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hylle06.itea.ntnu.no (Postfix) with ESMTP id 45DEF662646; Thu, 28 Jan 2016 12:28:41 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at hylle06.itea.ntnu.no Received: from alumnimail01.it.ntnu.no (unknown [IPv6:2001:700:300:4::54]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hylle06.itea.ntnu.no (Postfix) with ESMTPS id 8E0B7662634; Thu, 28 Jan 2016 12:28:40 +0100 (CET) Received: from localhost (dslb-178-000-215-072.178.000.pools.vodafone-ip.de [178.0.215.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: suraev) by alumnimail01.it.ntnu.no (Postfix) with ESMTPSA id 46BF65E9CF; Thu, 28 Jan 2016 12:28:40 +0100 (CET) From: suraev@alumni.ntnu.no To: openbsc@lists.osmocom.org Subject: [PATCH 2/4] Fix error introduced in a15f05f1b43d8e85d9a3f72a0a Date: Thu, 28 Jan 2016 12:28:29 +0100 Message-Id: <1453980511-1787-2-git-send-email-suraev@alumni.ntnu.no> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1453980511-1787-1-git-send-email-suraev@alumni.ntnu.no> References: <1453980511-1787-1-git-send-email-suraev@alumni.ntnu.no> X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Development of the OpenBSC GSM base station controller List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Max Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" From: Max The code in bitvec_*_field was incorrectly ported from C++. This also affected bitvec_unhex which uses it. --- src/bitvec.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/bitvec.c b/src/bitvec.c index 7254674..407dfc8 100644 --- a/src/bitvec.c +++ b/src/bitvec.c @@ -389,6 +389,7 @@ int bitvec_unhex(struct bitvec *bv, const char *src) return 1; bitvec_write_field(bv, write_index, val, 4); + write_index += 4; } return 0; } @@ -407,7 +408,7 @@ uint64_t bitvec_read_field(struct bitvec *bv, unsigned int read_index, unsigned ui |= ((uint64_t)1 << (len - i - 1)); bv->cur_bit++; } - read_index += len; + return ui; } @@ -425,8 +426,8 @@ int bitvec_write_field(struct bitvec *bv, unsigned int write_index, uint64_t val if (rc) return rc; } - write_index += len; - return 0; + + return write_index + len; } /*! @} */