From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.1 From: Aleksei Nikiforov To: devel@lists.altlinux.org Date: Thu, 12 Dec 2019 12:57:11 +0300 Message-Id: <20191212095730.83787-3-darktemplar@altlinux.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191212095730.83787-1-darktemplar@altlinux.org> References: <20191211234857.GB17949@altlinux.org> <20191212095730.83787-1-darktemplar@altlinux.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Cc: Aleksei Nikiforov Subject: [devel] [PATCH for apt v2 02/21] Use correct types and type specifiers X-BeenThere: devel@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: ALT Linux Team development discussions List-Id: ALT Linux Team development discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Dec 2019 09:58:14 -0000 X-List-Received-Date: Thu, 12 Dec 2019 09:58:14 -0000 X-List-Received-Date: Thu, 12 Dec 2019 09:58:14 -0000 Archived-At: List-Archive: List-Post: Found via cppcheck: (warning) %li in format string (no. 1) requires 'long' but the argument type is 'unsigned long'. (warning) %llu in format string (no. 1) requires 'unsigned long long' but the argument type is 'signed long long'. And other similar warnings --- apt/apt-pkg/contrib/cdromutl.cc | 4 ++-- apt/apt-pkg/contrib/strutl.cc | 8 ++++---- apt/cmdline/acqprogress.cc | 4 ++-- apt/methods/connect.cc | 4 ++-- apt/methods/http.cc | 9 +++------ apt/methods/http.h | 2 +- 6 files changed, 14 insertions(+), 17 deletions(-) diff --git a/apt/apt-pkg/contrib/cdromutl.cc b/apt/apt-pkg/contrib/cdromutl.cc index 6101145..139be84 100644 --- a/apt/apt-pkg/contrib/cdromutl.cc +++ b/apt/apt-pkg/contrib/cdromutl.cc @@ -232,8 +232,8 @@ bool IdentCdrom(const string &CD,string &Res,unsigned int Version) return _error->Errno("statfs",_("Failed to stat the cdrom")); // We use a kilobyte block size to advoid overflow - sprintf(S,"%llu %llu",(long long)(Buf.f_blocks*(Buf.f_bsize/1024)), - (long long)(Buf.f_bfree*(Buf.f_bsize/1024))); + sprintf(S,"%llu %llu",(unsigned long long)(Buf.f_blocks*(Buf.f_bsize/1024)), + (unsigned long long)(Buf.f_bfree*(Buf.f_bsize/1024))); Hash.Add(S); sprintf(S,"-%u",Version); } diff --git a/apt/apt-pkg/contrib/strutl.cc b/apt/apt-pkg/contrib/strutl.cc index 6131d47..bde4ef5 100644 --- a/apt/apt-pkg/contrib/strutl.cc +++ b/apt/apt-pkg/contrib/strutl.cc @@ -292,23 +292,23 @@ string TimeToStr(unsigned long Sec) { if (Sec > 60*60*24) { - sprintf(S,"%lid %lih%lim%lis",Sec/60/60/24,(Sec/60/60) % 24,(Sec/60) % 60,Sec % 60); + sprintf(S,"%lud %luh%lum%lus",Sec/60/60/24,(Sec/60/60) % 24,(Sec/60) % 60,Sec % 60); break; } if (Sec > 60*60) { - sprintf(S,"%lih%lim%lis",Sec/60/60,(Sec/60) % 60,Sec % 60); + sprintf(S,"%luh%lum%lus",Sec/60/60,(Sec/60) % 60,Sec % 60); break; } if (Sec > 60) { - sprintf(S,"%lim%lis",Sec/60,Sec % 60); + sprintf(S,"%lum%lus",Sec/60,Sec % 60); break; } - sprintf(S,"%lis",Sec); + sprintf(S,"%lus",Sec); break; } diff --git a/apt/cmdline/acqprogress.cc b/apt/cmdline/acqprogress.cc index 8fa9420..ecf9c2e 100644 --- a/apt/cmdline/acqprogress.cc +++ b/apt/cmdline/acqprogress.cc @@ -215,10 +215,10 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner) { if (Mode == Short) snprintf(S,End-S," %lu%%", - long(double(I->CurrentSize*100.0)/double(I->TotalSize))); + (unsigned long) (double(I->CurrentSize*100.0)/double(I->TotalSize))); else snprintf(S,End-S,"/%sB %lu%%",SizeToStr(I->TotalSize).c_str(), - long(double(I->CurrentSize*100.0)/double(I->TotalSize))); + (unsigned long) (double(I->CurrentSize*100.0)/double(I->TotalSize))); } S += strlen(S); snprintf(S,End-S,"]"); diff --git a/apt/methods/connect.cc b/apt/methods/connect.cc index f086a7e..a25d6b4 100644 --- a/apt/methods/connect.cc +++ b/apt/methods/connect.cc @@ -162,7 +162,7 @@ bool Connect(const string &Host,int Port,const char *Service,int DefPort,std::un // Convert the port name/number char ServStr[300]; if (Port != 0) - snprintf(ServStr,sizeof(ServStr),"%u",Port); + snprintf(ServStr,sizeof(ServStr),"%u",(unsigned) Port); else snprintf(ServStr,sizeof(ServStr),"%s",Service); @@ -198,7 +198,7 @@ bool Connect(const string &Host,int Port,const char *Service,int DefPort,std::un { if (DefPort != 0) { - snprintf(ServStr,sizeof(ServStr),"%u",DefPort); + snprintf(ServStr,sizeof(ServStr),"%u",(unsigned) DefPort); DefPort = 0; continue; } diff --git a/apt/methods/http.cc b/apt/methods/http.cc index da3e646..6d9a642 100644 --- a/apt/methods/http.cc +++ b/apt/methods/http.cc @@ -588,7 +588,7 @@ bool ServerState::HeaderLine(const string &Line) if (sscanf(Val.c_str(),"bytes %llu-%*u/%llu",&StartPos,&Size) != 2) return _error->Error(_("The http server sent an invalid Content-Range header")); - if ((unsigned long long)StartPos > Size) + if (StartPos > Size) return _error->Error(_("This http server has broken range support")); return true; } @@ -1016,11 +1016,8 @@ int HttpMethod::DealWithHeaders(FetchResult &Res,ServerState *Srv) FailTime = Srv->Date; // Set the expected size - if (Srv->StartPos >= 0) - { - Res.ResumePoint = Srv->StartPos; - ftruncate(File->Fd(),Srv->StartPos); - } + Res.ResumePoint = Srv->StartPos; + ftruncate(File->Fd(),Srv->StartPos); // Set the start point lseek(File->Fd(),0,SEEK_END); diff --git a/apt/methods/http.h b/apt/methods/http.h index b5c2d68..3b50e73 100644 --- a/apt/methods/http.h +++ b/apt/methods/http.h @@ -87,7 +87,7 @@ struct ServerState // These are some statistics from the last parsed header lines unsigned long long Size; - signed long long StartPos; + unsigned long long StartPos; time_t Date; bool HaveContent; enum {Chunked,Stream,Closes} Encoding; -- 2.24.1