From patchwork Sat Aug 3 01:55:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 1141422 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=uclibc.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=uclibc-bounces@uclibc.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kw5I4XuP"; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 460nF64lsYz9sNC for ; Sat, 3 Aug 2019 11:56:09 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 5A8098820C; Sat, 3 Aug 2019 01:56:06 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1w+5nTUq5ff9; Sat, 3 Aug 2019 01:56:05 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 6A5BD87E5D; Sat, 3 Aug 2019 01:56:05 +0000 (UTC) X-Original-To: uclibc@lists.busybox.net Delivered-To: uclibc@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id B33801BF360 for ; Sat, 3 Aug 2019 01:56:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id AFEDD87E5D for ; Sat, 3 Aug 2019 01:56:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sawC2nh1IIEL for ; Sat, 3 Aug 2019 01:56:03 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by hemlock.osuosl.org (Postfix) with ESMTPS id 2291687E55 for ; Sat, 3 Aug 2019 01:56:03 +0000 (UTC) Received: by mail-pg1-f172.google.com with SMTP id w10so36898775pgj.7 for ; Fri, 02 Aug 2019 18:56:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=3uTj4RlpH3KOQcKb5RVzVoWP0eZpnm3QLC0scjlUbqw=; b=kw5I4XuP6/64VB7mRdQquz+DA2VkStqjLQMbmYRl+q+7OoqG3HXfZXqXCcUtAY5Mez zKgAi1pme6gaQ5tIUI/q2S+yo9zQ2yZGsTfRmiISG3pgXmdXZi1hdSnQozFRUZhaZX9q hzEqK1YbWrp7holi1xhvZm91ZQzrh+bCYEjFC4EJxBtUvju59VRVFVdtefUtuepihLct skEvvA7YbMxkhge+I+8rwtCkDUZG8rg30rX6jIzqbGmgEiZQy/ofmE8f5CW6NTDfZTsV 5T8fYzXUtAtqZoYYWrx76hje8HHEOZKHK6MUp6gG/ox+t/ly9Nweeu2zne3YzrCfP/9T Jyew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=3uTj4RlpH3KOQcKb5RVzVoWP0eZpnm3QLC0scjlUbqw=; b=aJF8fWKcVUfpLzNM9OiqLNbGX4TVh5xiYeMF79j+zg+nQUThMCNYsjOxOpXS2Dl572 h3jVTakdmq0accz2wXWcsMQObCLQHk/bzxUhdRgo4HS5+X0y1gFNSgWEgHeblL3ofwxY pKHHMNXkmw20Q/ZQykAKfnqCyX4Sd8dRLBbWO7ytTb+gLDxhY0d5us8muGeYpu1h+hw7 7Pm3LkWF22XTdd9wCDm6Hq3RoitKOn+5t1AcTy8MWZrbVc1ObBGE2dVpp3LW58wusElg i7P3xeRDjROZTiXO06VvIPcCZPv+ek3vWfTuxJAAVVnpAgyiilEQNnqWerHRjit1naPM hJ7g== X-Gm-Message-State: APjAAAVoumeXbpnZg2iez118e9HDo1CetKOF+XsQAeousHG5JJ45Ps/H XBtqZC5ZrmIUg9vkLpbFGeLMegVxCOo= X-Google-Smtp-Source: APXvYqx8dcsXEhOwYwNlQU0ou+Vp/1MUujgU+nzSRRUQpJAy2L8BRaXTLTEnDsnnw29OaCc47aWgfQ== X-Received: by 2002:a17:90a:fa07:: with SMTP id cm7mr7181912pjb.115.1564797362460; Fri, 02 Aug 2019 18:56:02 -0700 (PDT) Received: from localhost.localdomain (76-14-106-55.rk.wavecable.com. [76.14.106.55]) by smtp.gmail.com with ESMTPSA id s24sm33424167pgm.3.2019.08.02.18.56.01 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 18:56:01 -0700 (PDT) From: Rosen Penev To: uclibc@uclibc.org Subject: [PATCH 4/4] include: Replace C style casts with static_cast Date: Fri, 2 Aug 2019 18:55:58 -0700 Message-Id: <20190803015558.4143-4-rosenp@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803015558.4143-1-rosenp@gmail.com> References: <20190803015558.4143-1-rosenp@gmail.com> X-BeenThere: uclibc@uclibc.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Discussion and development of uClibc \(the embedded C library\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: uclibc-bounces@uclibc.org Sender: "uClibc" Found with Clang's -Wold-style-cast Signed-off-by: Rosen Penev --- include/char_traits | 6 +++--- include/memory | 6 +++--- include/string | 2 +- include/vector | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/char_traits b/include/char_traits index 36eae36..1d33f39 100644 --- a/include/char_traits +++ b/include/char_traits @@ -52,7 +52,7 @@ namespace std{ static char_type to_char_type(const int_type & i); inline static int_type to_int_type(const char_type & c){ - return (short int)(unsigned char)c; + return static_cast(static_cast(c)); } inline static bool eq_int_type(const int_type & a, const int_type & b){ @@ -71,7 +71,7 @@ namespace std{ } inline static char_type* move(char_type* s1, const char_type* s2, size_t n){ - return (char*) memmove(s1, s2, n); + return static_cast(memmove(s1, s2, n)); } inline static char_type* copy(char_type* s1, const char_type* s2, size_t n){ @@ -82,7 +82,7 @@ namespace std{ } inline static char_type* assign(char_type* s, size_t n, char_type a){ - return (char *)memset(s, a, n); + return static_cast(memset(s, a, n)); } inline static int compare(const char_type* s1, const char_type* s2, size_t n){ diff --git a/include/memory b/include/memory index 9ce6559..37ac637 100644 --- a/include/memory +++ b/include/memory @@ -63,15 +63,15 @@ public: //Space for n Ts pointer allocate(size_type n, typename allocator::const_pointer = 0){ - return (T*)(::operator new( n * sizeof(T) )); + return static_cast(::operator new( n * sizeof(T) )); } void deallocate(pointer p, size_type){ ::operator delete(p); } //Use placement new to engage the constructor - void construct(pointer p, const T& val) { new((void*)p) T(val); } - void destroy(pointer p){ ((T*)p)->~T(); } //Call destructor + void construct(pointer p, const T& val) { new(static_cast(p)) T(val); } + void destroy(pointer p){ (static_cast(p))->~T(); } //Call destructor size_type max_size() const _UCXX_USE_NOEXCEPT; template struct rebind { typedef allocator other; }; diff --git a/include/string b/include/string index a790715..8cfa8b0 100644 --- a/include/string +++ b/include/string @@ -70,7 +70,7 @@ public: typedef typename vector::reverse_iterator reverse_iterator; typedef typename vector::const_reverse_iterator const_reverse_iterator; - static const size_type npos = (size_type)-1; + static const size_type npos = static_cast(-1); explicit _UCXXEXPORT basic_string(const A& al = A()) : vector(al){ return; } diff --git a/include/vector b/include/vector index 8310bc1..3cf64ed 100644 --- a/include/vector +++ b/include/vector @@ -180,7 +180,7 @@ namespace std{ } _UCXXEXPORT size_type max_size() const{ - return ((size_type)(-1)) / sizeof(T); + return static_cast(-1) / sizeof(T); } void downsize(size_type sz);