mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Patrick Cheng <patrickyccheng@gmail.com>
To: musl@lists.openwall.com
Subject: [Patch] reduced warnings reported by clang
Date: Tue, 09 Jan 2018 16:48:02 +0000	[thread overview]
Message-ID: <CAKb-6jvgsojU1c1P2oSP5uJN1Fwdy-4b3joDDXNYXdbcTN5CyQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1514 bytes --]

Hello,

Not sure if it's the version of clang that I was using, or the warning
level/toggle on the project that I was compiling, but Musl headers were
causing a number of warnings.

Added extra parenthesis, so it's more explicit the precedence of | vs &

Added 'const' to the typecasting. Clang didn't like const casting.



diff --git a/include/endian.h b/include/endian.h
index 1bd4445..a7a9b6a 100644
--- a/include/endian.h
+++ b/include/endian.h
@@ -24,17 +24,17 @@

 static __inline uint16_t __bswap16(uint16_t __x)
 {
- return __x<<8 | __x>>8;
+ return (__x<<8) | (__x>>8);
 }

 static __inline uint32_t __bswap32(uint32_t __x)
 {
- return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24;
+ return __x>>24 | (__x>>8&0xff00) | (__x<<8&0xff0000) | __x<<24;
 }

 static __inline uint64_t __bswap64(uint64_t __x)
 {
- return __bswap32(__x)+0ULL<<32 | __bswap32(__x>>32);
+ return (__bswap32(__x)+0ULL)<<32 | __bswap32(__x>>32);
 }

 #if __BYTE_ORDER == __LITTLE_ENDIAN
diff --git a/include/sched.h b/include/sched.h
index 05d40b1..4d1a599 100644
--- a/include/sched.h
+++ b/include/sched.h
@@ -95,8 +95,8 @@ static __inline void __CPU_##func##_S(size_t __size,
cpu_set_t *__dest, \
 { \
  size_t __i; \
  for (__i=0; __i<__size/sizeof(long); __i++) \
- ((unsigned long *)__dest)[__i] = ((unsigned long *)__src1)[__i] \
- op ((unsigned long *)__src2)[__i] ; \
+ ((unsigned long *)__dest)[__i] = ((const unsigned long *)__src1)[__i] \
+ op ((const unsigned long *)__src2)[__i] ; \
 }

 __CPU_op_func_S(AND, &)

[-- Attachment #2: Type: text/html, Size: 4499 bytes --]

             reply	other threads:[~2018-01-09 16:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-09 16:48 Patrick Cheng [this message]
2018-01-09 17:01 ` Markus Wichmann
2018-01-09 17:07   ` Rich Felker
2018-01-09 17:49     ` Patrick Cheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKb-6jvgsojU1c1P2oSP5uJN1Fwdy-4b3joDDXNYXdbcTN5CyQ@mail.gmail.com \
    --to=patrickyccheng@gmail.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).