From patchwork Wed Apr 1 16:15:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 6141131 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E4B539F399 for ; Wed, 1 Apr 2015 16:12:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 04A2E2035E for ; Wed, 1 Apr 2015 16:12:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0178720364 for ; Wed, 1 Apr 2015 16:12:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 57ACD6E34E; Wed, 1 Apr 2015 09:12:32 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by gabe.freedesktop.org (Postfix) with ESMTP id ADC506E34E for ; Wed, 1 Apr 2015 09:12:30 -0700 (PDT) Received: by wixo5 with SMTP id o5so55101929wix.1 for ; Wed, 01 Apr 2015 09:12:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=N9GFGoJWdsbVVR476Lk9Vluh/RAXPct9NCRK0e4n5pA=; b=KqRPjj2MRDdZeUxM4l0TvoJK5kMamSOo+A0sG+wKPo3KnfHJkh2qTqrcB9bxOuBGDK kwBa963Q+Um/Vl8AHsWEeFhqEM3P4OiGl2XsKTO+WyvCAmHDnCCdwK7NT7rPDITgddbP GdnrHILj0eQeCdeRGXHehVw6KAQGPc5Cf7GzMvYZlvJ3wytfbvGOPaNRYSHzhD+NtGSS AVHWAR7Uvznc3j9QWSRAAB0/mSMzBNq45+XQxcgppIpznVf4G+DgF0XaDfjpSK8IZZo9 sd9CQjQ74HIecfgDieqWPjbAx5e3eyYSDNOzlpIUPY5lmQimdh+pqMPcFG7mHOd3Mp8t xJbQ== X-Received: by 10.180.75.72 with SMTP id a8mr16656996wiw.70.1427904750027; Wed, 01 Apr 2015 09:12:30 -0700 (PDT) Received: from arch-x220.localdomain (cpc12-croy20-2-0-cust52.croy.cable.virginm.net. [82.44.54.53]) by mx.google.com with ESMTPSA id ge8sm3319498wjc.32.2015.04.01.09.12.28 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Apr 2015 09:12:29 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 04/24] radeon: annotate bof_incref, bof_string functions as static Date: Wed, 1 Apr 2015 17:15:15 +0100 Message-Id: <1427904935-14387-5-git-send-email-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.3.1 In-Reply-To: <1427904935-14387-1-git-send-email-emil.l.velikov@gmail.com> References: <1427904935-14387-1-git-send-email-emil.l.velikov@gmail.com> Cc: Jerome Glisse , emil.l.velikov@gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Used locally in bof.c. Cc: Jerome Glisse Signed-off-by: Emil Velikov --- radeon/bof.c | 96 ++++++++++++++++++++++++++++++------------------------------ radeon/bof.h | 3 -- 2 files changed, 48 insertions(+), 51 deletions(-) diff --git a/radeon/bof.c b/radeon/bof.c index 6f3760a..20901a0 100644 --- a/radeon/bof.c +++ b/radeon/bof.c @@ -45,6 +45,54 @@ static int bof_entry_grow(bof_t *bof) return 0; } +static void bof_incref(bof_t *bof) +{ + bof->refcount++; +} + +void bof_decref(bof_t *bof) +{ + unsigned i; + + if (bof == NULL) + return; + if (--bof->refcount > 0) + return; + for (i = 0; i < bof->array_size; i++) { + bof_decref(bof->array[i]); + bof->array[i] = NULL; + } + bof->array_size = 0; + if (bof->file) { + fclose(bof->file); + bof->file = NULL; + } + free(bof->array); + free(bof->value); + free(bof); +} + +/* + * string + */ +static bof_t *bof_string(const char *value) +{ + bof_t *string = bof_object(); + + if (string == NULL) + return NULL; + string->type = BOF_TYPE_STRING; + string->size = strlen(value) + 1; + string->value = calloc(1, string->size); + if (string->value == NULL) { + bof_decref(string); + return NULL; + } + strcpy(string->value, value); + string->size += 12; + return string; +} + /* * object */ @@ -160,27 +208,6 @@ void *bof_blob_value(bof_t *bof) } /* - * string - */ -bof_t *bof_string(const char *value) -{ - bof_t *string = bof_object(); - - if (string == NULL) - return NULL; - string->type = BOF_TYPE_STRING; - string->size = strlen(value) + 1; - string->value = calloc(1, string->size); - if (string->value == NULL) { - bof_decref(string); - return NULL; - } - strcpy(string->value, value); - string->size += 12; - return string; -} - -/* * int32 */ bof_t *bof_int32(int32_t value) @@ -316,33 +343,6 @@ out_err: return -EINVAL; } -void bof_incref(bof_t *bof) -{ - bof->refcount++; -} - -void bof_decref(bof_t *bof) -{ - unsigned i; - - if (bof == NULL) - return; - if (--bof->refcount > 0) - return; - for (i = 0; i < bof->array_size; i++) { - bof_decref(bof->array[i]); - bof->array[i] = NULL; - } - bof->array_size = 0; - if (bof->file) { - fclose(bof->file); - bof->file = NULL; - } - free(bof->array); - free(bof->value); - free(bof); -} - static int bof_file_write(bof_t *bof, FILE *file) { unsigned i; diff --git a/radeon/bof.h b/radeon/bof.h index 8e952c1..4dae923 100644 --- a/radeon/bof.h +++ b/radeon/bof.h @@ -63,14 +63,11 @@ extern unsigned bof_array_size(bof_t *bof); extern bof_t *bof_blob(unsigned size, void *value); extern unsigned bof_blob_size(bof_t *bof); extern void *bof_blob_value(bof_t *bof); -/* string */ -extern bof_t *bof_string(const char *value); /* int32 */ extern bof_t *bof_int32(int32_t value); extern int32_t bof_int32_value(bof_t *bof); /* common functions */ extern void bof_decref(bof_t *bof); -extern void bof_incref(bof_t *bof); extern int bof_dump_file(bof_t *bof, const char *filename); static inline int bof_is_object(bof_t *bof){return (bof->type == BOF_TYPE_OBJECT);}