From patchwork Sat Oct 17 01:17:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Schiffer X-Patchwork-Id: 531596 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 831291402B2 for ; Sat, 17 Oct 2015 12:18:47 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id E8BAA280331; Sat, 17 Oct 2015 03:16:18 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00, T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 51D6328013B for ; Sat, 17 Oct 2015 03:16:03 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 CL_IP_EQ_FROM_MX=-3.1; rate: -7.6 Received: from chaos.universe-factory.net (chaos.universe-factory.net [37.72.148.22]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Sat, 17 Oct 2015 03:16:01 +0200 (CEST) Received: from avalon.neoraider.dn42 (unknown [IPv6:fd1b:c28a:2fd6:0:a006:78ff:febd:a2f0]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by chaos.universe-factory.net (Postfix) with ESMTPSA id 95EE418A3A8 for ; Sat, 17 Oct 2015 03:17:35 +0200 (CEST) From: Matthias Schiffer To: openwrt-devel@lists.openwrt.org Date: Sat, 17 Oct 2015 03:17:28 +0200 Message-Id: X-Mailer: git-send-email 2.6.1 In-Reply-To: References: In-Reply-To: References: Subject: [OpenWrt-Devel] [PATCH 1/3] tools/firmware-utils: tplink-safeloader: clean up code X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" There is no reason for the internal functions not to be static. Signed-off-by: Matthias Schiffer --- tools/firmware-utils/src/tplink-safeloader.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/firmware-utils/src/tplink-safeloader.c b/tools/firmware-utils/src/tplink-safeloader.c index 9c5bb54..4607a1d 100644 --- a/tools/firmware-utils/src/tplink-safeloader.c +++ b/tools/firmware-utils/src/tplink-safeloader.c @@ -152,7 +152,7 @@ static const unsigned char cpe510_support_list[] = /** Allocates a new image partition */ -struct image_partition_entry alloc_image_partition(const char *name, size_t len) { +static struct image_partition_entry alloc_image_partition(const char *name, size_t len) { struct image_partition_entry entry = {name, len, malloc(len)}; if (!entry.data) error(1, errno, "malloc"); @@ -161,12 +161,12 @@ struct image_partition_entry alloc_image_partition(const char *name, size_t len) } /** Frees an image partition */ -void free_image_partition(struct image_partition_entry entry) { +static void free_image_partition(struct image_partition_entry entry) { free(entry.data); } /** Generates the partition-table partition */ -struct image_partition_entry make_partition_table(const struct flash_partition_entry *p) { +static struct image_partition_entry make_partition_table(const struct flash_partition_entry *p) { struct image_partition_entry entry = alloc_image_partition("partition-table", 0x800); char *s = (char *)entry.data, *end = (char *)(s+entry.size); @@ -202,7 +202,7 @@ static inline uint8_t bcd(uint8_t v) { /** Generates the soft-version partition */ -struct image_partition_entry make_soft_version(uint32_t rev) { +static struct image_partition_entry make_soft_version(uint32_t rev) { struct image_partition_entry entry = alloc_image_partition("soft-version", sizeof(struct soft_version)); struct soft_version *s = (struct soft_version *)entry.data; @@ -233,14 +233,14 @@ struct image_partition_entry make_soft_version(uint32_t rev) { } /** Generates the support-list partition */ -struct image_partition_entry make_support_list(const unsigned char *support_list, size_t len) { +static struct image_partition_entry make_support_list(const unsigned char *support_list, size_t len) { struct image_partition_entry entry = alloc_image_partition("support-list", len); memcpy(entry.data, support_list, len); return entry; } /** Creates a new image partition with an arbitrary name from a file */ -struct image_partition_entry read_file(const char *part_name, const char *filename, bool add_jffs2_eof) { +static struct image_partition_entry read_file(const char *part_name, const char *filename, bool add_jffs2_eof) { struct stat statbuf; if (stat(filename, &statbuf) < 0) @@ -300,7 +300,7 @@ struct image_partition_entry read_file(const char *part_name, const char *filena I think partition-table must be the first partition in the firmware image. */ -void put_partitions(uint8_t *buffer, const struct image_partition_entry *parts) { +static void put_partitions(uint8_t *buffer, const struct image_partition_entry *parts) { size_t i; char *image_pt = (char *)buffer, *end = image_pt + 0x800; @@ -325,7 +325,7 @@ void put_partitions(uint8_t *buffer, const struct image_partition_entry *parts) } /** Generates and writes the image MD5 checksum */ -void put_md5(uint8_t *md5, uint8_t *buffer, unsigned int len) { +static void put_md5(uint8_t *md5, uint8_t *buffer, unsigned int len) { MD5_CTX ctx; MD5_Init(&ctx); @@ -349,7 +349,7 @@ void put_md5(uint8_t *md5, uint8_t *buffer, unsigned int len) { 1014-1813 Image partition table (2048 bytes, padded with 0xff) 1814-xxxx Firmware partitions */ -void * generate_factory_image(const unsigned char *vendor, size_t vendor_len, const struct image_partition_entry *parts, size_t *len) { +static void * generate_factory_image(const unsigned char *vendor, size_t vendor_len, const struct image_partition_entry *parts, size_t *len) { *len = 0x1814; size_t i; @@ -381,7 +381,7 @@ void * generate_factory_image(const unsigned char *vendor, size_t vendor_len, co should be generalized when TP-LINK starts building its safeloader into hardware with different flash layouts. */ -void * generate_sysupgrade_image(const struct flash_partition_entry *flash_parts, const struct image_partition_entry *image_parts, size_t *len) { +static void * generate_sysupgrade_image(const struct flash_partition_entry *flash_parts, const struct image_partition_entry *image_parts, size_t *len) { const struct flash_partition_entry *flash_os_image = &flash_parts[5]; const struct flash_partition_entry *flash_soft_version = &flash_parts[6]; const struct flash_partition_entry *flash_support_list = &flash_parts[7]; @@ -459,7 +459,7 @@ static void do_cpe510(const char *output, const char *kernel_image, const char * /** Usage output */ -void usage(const char *argv0) { +static void usage(const char *argv0) { fprintf(stderr, "Usage: %s [OPTIONS...]\n" "\n"