From patchwork Fri Oct 20 23:31:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kalashnikov X-Patchwork-Id: 828853 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4010:c07::239; helo=mail-lf0-x239.google.com; envelope-from=swupdate+bncbd7ivpnd34mbbreovlhqkgqekdrjaoq@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="M1gUb55Z"; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kRmeOox+"; dkim-atps=neutral Received: from mail-lf0-x239.google.com (mail-lf0-x239.google.com [IPv6:2a00:1450:4010:c07::239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yJhrW2Dmpz9t3J for ; Sat, 21 Oct 2017 10:31:21 +1100 (AEDT) Received: by mail-lf0-x239.google.com with SMTP id a132sf3343083lfa.17 for ; Fri, 20 Oct 2017 16:31:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1508542276; cv=pass; d=google.com; s=arc-20160816; b=Cdobz0Rfx07Sqr6T33+O/kC6DnurQ4N6RglrP/RCICZ9GEuXR31WGMq2F/vopDX42A b2KvZOcVOYtN4H541pCH3DQn5MMUBwV2f9cIMnKT7I3MfOiX1l3l0n4SPKH50wi2Vywg lvoFpVbpsIiyivDVQwWLVTs0eVnnGWbT4kbWYFBkUQH2U50P15U/b38pzU01o8O6NdCU O2SpKKifHuWH0xpNvSC2fY1lUUBnvY2uWx/WRY7z1NrkG504hNz3rc5A9PNFbYo9C9Uv 1dXKIc9mx9lrnxFl+ueYGwDlL5DnvKU7WQHg+nDLtXXlqSyGSDaodrOHMW+zfWz0KI8R cJCw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:to:subject:message-id:date:from :mime-version:arc-authentication-results:arc-message-signature :sender:dkim-signature:dkim-signature:arc-authentication-results; bh=mendW7mv8KNQLF/vXNvwVNuFCJfGEnNYlsCzEd94h7A=; b=arlM+yKuJyMD5k5HtKntba0icA8pKzrnRorhy4uZr3KyyNr30HcIq2VhOVYGE6+NrI HLydrhQLkDc+O9FS1J2COs2W85P6x0FrEoE6u4fIKZqNCJmWmkQNSnTPwbCcfTYMt/ci hneMMpt+QwJK5MbP3Hs+7n2J8pOvtW6eiZCMVzxkcWU0Jbw8q5I40QatkCskf7KBmr3H cjbXmAGICOSDJtC/xtZj7V20E9J9RauuG0L+KTgnviMxZ4qhO6+1TRTAKGym6SM5YCMK 2VFBQbmkC7iwdraGHH7o/NBHybB1Mn0YYZf78BmWCe8FV4ghzf0WBViMC9hdkhLBIutw SXmA== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VZOMdjco; spf=pass (google.com: domain of lunix0x@gmail.com designates 2a00:1450:400c:c09::241 as permitted sender) smtp.mailfrom=lunix0x@gmail.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:date:message-id:subject:to :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=mendW7mv8KNQLF/vXNvwVNuFCJfGEnNYlsCzEd94h7A=; b=M1gUb55ZMho8E6JB0S2u536d/rx954Up2kAhekqpARjQQB9MXyqnLAr70zXSLOYWkZ ro9+sOJxoN5X+lC3ijidnHERcv8zpOhfLflZxnB/5JmE/vrDtwoqjea/cRLw4ZwZzKa3 wOe9wardZGOXtElMSUHmm2qVuCEz+o0jw0r9S5SktMORUkkgJEhGzr3YqrYM7Ze48S+I TadGhuNs4wbDTMCzLjU8MBrsir4u+SS19gXRHPSJ82+y5XGAQC9m3FBJ2h6KuRPvk7gW A01bqoZngiHoYPbXkwYT+Bc2DHK5BidSVS4uKh3CeKs9bmkwSAcR/5C9sCSh5t0+f1Pr 6J2A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=mendW7mv8KNQLF/vXNvwVNuFCJfGEnNYlsCzEd94h7A=; b=kRmeOox+gW2AO6IPx6tfiV5oPPtvwKJzg5nmPiXi1+tVspHi73E03+ITxLz/j1gMYB 0mciDdSjA1jLO7SHgO07eqTNU6mbW/RuPdY7Ax67fYndfxXMEjFvdiX7hL9Qvr+3AF8j K1mmrTqy5z3ASmqXBnNkDkn51oGS1H1RFJImyb7kqtED7N6JDmuq1HLIZaTfkmkN4Off pRHIx71qyWIehc25GQosAZ2ELQxkezVERv/0PYsHTb3nPjykPRBH3AJ0htFrjJg4CQtI LThxZ2kUdGpYNj9TH8hvt/JIFYF7jlsjue8axbQXeFI7gHLp3W7Wd5tdsP4hYiCQ4pGO B2HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:date:message-id:subject :to:x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help :list-archive:list-subscribe:list-unsubscribe; bh=mendW7mv8KNQLF/vXNvwVNuFCJfGEnNYlsCzEd94h7A=; b=NOvKYPgaCzDSEU15hl+uNGgAhwYCFzL0DnTZUm8eFn4qsO8WmAjhW8oQtD8jvFarzk OlO3HZVUP8GQQmLynuisbw3fds2RtrU8kt9YEygwsFUnoeuSg+Qv3XszoZLYR2ou4vvA lr/FNAA5y12KC/zLyw3xTvjP+zCvvduqBoF0PPRGOVyF1xHwflYbgxz1SP/oLBiX8/Bk KwgYziie6OZ2ETE1QdO6rgrgDxx2T2LQSMOWuIMJOLdjYZgd4gyUcaaSAnxdgGSb1mKH U8G2AEkUthWw7tPonRWFsIZv1L093IlhkmU1mYZ62TjcIa6a1dizs2WBEDcZyTDJg0ER q2Og== Sender: swupdate@googlegroups.com X-Gm-Message-State: AMCzsaXuDyduDhIbwMmK3zKbzzcYhmeZwfAuo+/+9TRidLsZY1MkVKtS PxM5MzfTJjOPgFqN6kyLrnc= X-Google-Smtp-Source: ABhQp+RK7fs0ruN8WDaZZaldqI0yEsTvPausOscCx0XxT/kxAArR5lz9sMnt6BYWySvG5KcqqtaAbA== X-Received: by 10.25.202.14 with SMTP id a14mr19329lfg.6.1508542276370; Fri, 20 Oct 2017 16:31:16 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 10.46.99.220 with SMTP id s89ls1559582lje.14.gmail; Fri, 20 Oct 2017 16:31:15 -0700 (PDT) X-Received: by 10.46.2.217 with SMTP id y86mr230031lje.27.1508542275857; Fri, 20 Oct 2017 16:31:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508542275; cv=none; d=google.com; s=arc-20160816; b=TSdqX1w3tDHIXX8UrBxhpAsfNswdp+afWXp+JHNygho4/ae3lebQk+qdPVsQDNE6cF /rsSq5sq26DnmPYcXlSVMZtzgNgyNUakkwrbCGJeyip4w8OX3ElwTN35rioaUfu4frtX rPdTAWasdaT2f+JZy2Oy9CsgUJh9C3GhOtsDlLNntRL2YEJ7iEBgqVaIGl+QS4IYlZAK VZzqhlZttqph67l4H29pc8eJvBZRj/nWW+d30dZ7GmYDQvUKaaM/k1JfOgvZDUFNWUJO d9UqHzIVFkHC2vy28tJ0sRY2rtdn/KjlZAGiGsfU9L6/81DNsVI335R6i8X1ckaXBmVA MYAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:mime-version:dkim-signature :arc-authentication-results; bh=oCMtajZrf2a8Zm/UTgTlwABZ+JzOopzqzeh05CCLW8Y=; b=FbrOiGxFHFrca7JTtFqKzhtPorp/hhywo+7srZR91bJ/3z8+E9pnRT/tmnScixdtBJ rLSmwFBA2Yc54b1BRa08rzJ6ptGVeaBO2SpfgevOVV8u5xa5TOCpZ7mSeTcgmXriFXbj SsykUdxMYSWQLJ+8eqazJHcfFpIYWCITIKwRh80EWLQ7l5QevyR+yV2cFCroj3VNse8g v2OEs0h3TcJJrbb5On54ZoMs6V3PYWUh75YBN1i7niufVQ74kjTzHEOLE/NepD6YL9vx AH2ctt9LAOnAqE2dGOfWk2cb73KizzleTbQL4hIIsz5B/N5eH1wGxAA8QJ13XhH3OITe zeQg== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VZOMdjco; spf=pass (google.com: domain of lunix0x@gmail.com designates 2a00:1450:400c:c09::241 as permitted sender) smtp.mailfrom=lunix0x@gmail.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com. [2a00:1450:400c:c09::241]) by gmr-mx.google.com with ESMTPS id r17si133428ljb.2.2017.10.20.16.31.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Oct 2017 16:31:15 -0700 (PDT) Received-SPF: pass (google.com: domain of lunix0x@gmail.com designates 2a00:1450:400c:c09::241 as permitted sender) client-ip=2a00:1450:400c:c09::241; Received: by mail-wm0-x241.google.com with SMTP id f4so568223wme.0 for ; Fri, 20 Oct 2017 16:31:15 -0700 (PDT) X-Received: by 10.28.156.23 with SMTP id f23mr287860wme.128.1508542274997; Fri, 20 Oct 2017 16:31:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.1.67 with HTTP; Fri, 20 Oct 2017 16:31:14 -0700 (PDT) From: Roman Kalashnikov Date: Sat, 21 Oct 2017 02:31:14 +0300 Message-ID: Subject: [swupdate] WIP: [PATCH] Fix types mistmatch To: swupdate X-Original-Sender: lunix0x@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VZOMdjco; spf=pass (google.com: domain of lunix0x@gmail.com designates 2a00:1450:400c:c09::241 as permitted sender) smtp.mailfrom=lunix0x@gmail.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Signed-off-by: Roman Kalashnikov --- archival/gun.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (me->total ? me->total : 1)); if (percent != (unsigned int)me->percent) { @@ -354,7 +357,7 @@ static int lunpipe(unsigned have, unsigned char *next, struct ind *indp, prematurely or a write error occurs, or Z_ERRNO if junk (not a another gzip stream) follows a valid gzip stream. */ -static int gunpipe(z_stream *strm, int infile, unsigned long *offs, int nbytes, int outfile, uint32_t *checksum, void *dgst) +static int gunpipe(z_stream *strm, int infile, unsigned long *offs, unsigned int nbytes, int outfile, uint32_t *checksum, void *dgst) { int ret, first, last; unsigned have, flags, len; @@ -492,7 +495,7 @@ static int gunpipe(z_stream *strm, int infile, unsigned long *offs, int nbytes, /* Process the gun command line arguments. See the command syntax near the beginning of this source file. */ -int decompress_image(int infile, unsigned long *offs, int nbytes, +int decompress_image(int infile, unsigned long *offs, unsigned int nbytes, int outfile, uint32_t *checksum, void *dgst) { int ret; diff --git a/archival/gun.c b/archival/gun.c index ade0379..3c09ad5 100644 --- a/archival/gun.c +++ b/archival/gun.c @@ -45,8 +45,8 @@ struct ind { unsigned char *inbuf; unsigned long *offs; unsigned long *checksum; - int nbytes; - int total; + unsigned int nbytes; + unsigned int total; int percent; void *dgst; }; @@ -56,6 +56,7 @@ struct ind { returns end-of-file or error. Return 0 on error. */ static unsigned in(void *in_desc, unsigned char **buf) { + unsigned int piece; int ret; unsigned len; unsigned char *next; @@ -66,20 +67,22 @@ static unsigned in(void *in_desc, unsigned char **buf) *buf = next; len = 0; do { - ret = PIECE; - if ((unsigned)ret > SIZE - len) - ret = (int)(SIZE - len); - if (ret > me->nbytes) - ret = me->nbytes; - ret = fill_buffer(me->infile, next, ret, me->offs, (uint32_t *)me->checksum, me->dgst); + piece = PIECE; + if (piece > SIZE - len) + piece = (int)(SIZE - len); + if (piece > me->nbytes) + piece = me->nbytes; + ret = fill_buffer(me->infile, next, ret, me->offs, (uint32_t *)me->checksum, me->dgst); if (ret < 0) { len = 0; break; } - next += ret; - len += ret; - me->nbytes -= ret; - } while (ret != 0 && len < SIZE); + else + piece = ret; + next += piece; + len += piece; + me->nbytes -= piece; + } while (piece != 0 && len < SIZE); percent = (unsigned int)(((double)(me->total - me->nbytes)) * 100 /