From patchwork Sun Oct 4 09:22:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Holger Freyther X-Patchwork-Id: 526079 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (unknown [IPv6:2a01:4f8:191:444b::2:7]) by ozlabs.org (Postfix) with ESMTP id AD7DC1402C4 for ; Sun, 4 Oct 2015 20:23:23 +1100 (AEDT) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id 2E1D384F3; Sun, 4 Oct 2015 09:23:22 +0000 (UTC) X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received: from gandharva.secretlabs.de (unknown [IPv6:2a01:4f8:161:8201::2:4]) by lists.osmocom.org (Postfix) with ESMTP id 3FD3E84DD for ; Sun, 4 Oct 2015 09:23:18 +0000 (UTC) Received: from localhost.localdomain (ip5b41fb99.dynamic.kabel-deutschland.de [91.65.251.153]) by gandharva.secretlabs.de (Postfix) with ESMTPSA id BD812577A0; Sun, 4 Oct 2015 09:23:17 +0000 (UTC) From: Holger Hans Peter Freyther To: openbsc@lists.osmocom.org Subject: [PATCH 2/6] osmux: Do not divide the number of bytes by eight. Date: Sun, 4 Oct 2015 11:22:50 +0200 Message-Id: <1443950574-75194-2-git-send-email-holger@freyther.de> X-Mailer: git-send-email 2.6.0 In-Reply-To: <1443950574-75194-1-git-send-email-holger@freyther.de> References: <1443950574-75194-1-git-send-email-holger@freyther.de> 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: , Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" From: Holger Hans Peter Freyther sizeof(uint8_t) == 1 and there is no need to create an array with 16 bytes and then only use the first two of them. This means the CID range is from 0 to 127 and we should be able to extend this to 256 by changing the array size to 32. Update the testcase now that we can have more than 16 calls with Osmux. --- openbsc/src/libmgcp/mgcp_osmux.c | 4 ++-- openbsc/tests/mgcp/mgcp_test.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openbsc/src/libmgcp/mgcp_osmux.c b/openbsc/src/libmgcp/mgcp_osmux.c index b0ef69f..30a81cb 100644 --- a/openbsc/src/libmgcp/mgcp_osmux.c +++ b/openbsc/src/libmgcp/mgcp_osmux.c @@ -536,7 +536,7 @@ int osmux_used_cid(void) { int i, j, used = 0; - for (i = 0; i < sizeof(osmux_cid_bitmap) / 8; i++) { + for (i = 0; i < sizeof(osmux_cid_bitmap); i++) { for (j = 0; j < 8; j++) { if (osmux_cid_bitmap[i] & (1 << j)) used += 1; @@ -550,7 +550,7 @@ int osmux_get_cid(void) { int i, j; - for (i = 0; i < sizeof(osmux_cid_bitmap) / 8; i++) { + for (i = 0; i < sizeof(osmux_cid_bitmap); i++) { for (j = 0; j < 8; j++) { if (osmux_cid_bitmap[i] & (1 << j)) continue; diff --git a/openbsc/tests/mgcp/mgcp_test.c b/openbsc/tests/mgcp/mgcp_test.c index 7b5de31..ec86c55 100644 --- a/openbsc/tests/mgcp/mgcp_test.c +++ b/openbsc/tests/mgcp/mgcp_test.c @@ -1186,7 +1186,7 @@ static void test_osmux_cid(void) osmux_put_cid(id); OSMO_ASSERT(osmux_used_cid() == 0); - for (i = 0; i < 16; ++i) { + for (i = 0; i < 128; ++i) { id = osmux_get_cid(); OSMO_ASSERT(id == i); OSMO_ASSERT(osmux_used_cid() == i + 1);