9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Alexander Kapshuk <alexander.kapshuk@gmail.com>
To: 9front@9front.org
Subject: [9front] [patch] games/blit: Make 32-bit unsigned complement zero-extended to 64 bits explicit to silence compiler warning
Date: Sat, 23 Nov 2024 17:32:54 +0200	[thread overview]
Message-ID: <CAJ1xhMXmSgMxHMPMNMe8__T+PDZ2sv_WhD=+138p_44rXQA+rA@mail.gmail.com> (raw)

Compilation outputs these warnings:

cpu% mk
6c -FTVw blit.c
6c -FTVw cpu.c
6c -FTVw mem.c
6c -FTVw telnet.c
warning: cpu.c:244 32-bit unsigned complement zero-extended to 64 bits
warning: cpu.c:255 32-bit unsigned complement zero-extended to 64 bits
warning: cpu.c:266 32-bit unsigned complement zero-extended to 64 bits
6l  -o 6.out blit.6 cpu.6 mem.6 telnet.6

Type cast one of the u32int variables involved in the expression to
u64int to make zero-extension explicit and silence compiler warning.

diff 0676a1ba51784e2b44ce9100965e4554e13e48b9 uncommitted
--- a/sys/src/games/blit/cpu.c
+++ b/sys/src/games/blit/cpu.c
@@ -241,7 +241,7 @@
  rS |= FLAGC;
  if((v & 0x80) != 0)
  rS |= FLAGN;
- if((~(w ^ u) & (v ^ u) & 0x80) != 0)
+ if((~((u64int)w ^ u) & (v ^ u) & 0x80) != 0)
  rS |= FLAGV;
  if((u8int)v != 0)
  rS &= ~FLAGZ;
@@ -252,7 +252,7 @@
  rS |= FLAGC;
  if((v & 0x8000) != 0)
  rS |= FLAGN;
- if((~(w ^ u) & (v ^ u) & 0x8000) != 0)
+ if((~((u64int)w ^ u) & (v ^ u) & 0x8000) != 0)
  rS |= FLAGV;
  if((u16int)v != 0)
  rS &= ~FLAGZ;
@@ -263,7 +263,7 @@
  rS |= FLAGC;
  if((v & 0x80000000) != 0)
  rS |= FLAGN;
- if((~(w ^ u) & (v ^ u) & 0x80000000) != 0)
+ if((~((u64int)w ^ u) & (v ^ u) & 0x80000000) != 0)
  rS |= FLAGV;
  if((u32int)v != 0)
  rS &= ~FLAGZ;

                 reply	other threads:[~2024-11-23 15:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='CAJ1xhMXmSgMxHMPMNMe8__T+PDZ2sv_WhD=+138p_44rXQA+rA@mail.gmail.com' \
    --to=alexander.kapshuk@gmail.com \
    --cc=9front@9front.org \
    /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.
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).