public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Simon Marchi <simark@simark.ca>
Cc: Kirill Radkin <kirill.radkin@syntacore.com>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	 Konstantin Vladimirov <konstantin.vladimirov@syntacore.com>,
	 Ivan Tetyushkin <ivan.tetyushkin@syntacore.com>
Subject: Re: [PATCH] [gdbserver] Fix overflow detection in gdbserver
Date: Fri, 22 Dec 2023 08:41:41 -0700	[thread overview]
Message-ID: <87edfe2qiy.fsf@tromey.com> (raw)
In-Reply-To: <477a743c-b318-4089-bfbc-0035686b4cad@simark.ca> (Simon Marchi's message of "Thu, 21 Dec 2023 14:42:21 -0500")

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

>> +      if (count >= max_count || (static_cast<T>(-1) < 0
>> +&& count == (max_count - 1)
>> +&& firstdigit >= 0x8))
>> return -1;

Simon> I guess that the static_cast thing is to determine if the type is signed
Simon> or not?  Can you give it a name, for clarity, like (maybe there's a
Simon> better way, just an example):

Simon>   constexpr bool is_signed = static_cast<T> (-1) < 0;

We also have uses of std::is_signed<> and std::is_unsigned<> in the tree
already, so just using those is probably preferable, assuming this code
does what I think it does.

Tom

  reply	other threads:[~2023-12-22 15:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-21  8:38 Kirill Radkin
2023-12-21 19:42 ` Simon Marchi
2023-12-22 15:41   ` Tom Tromey [this message]
2024-01-10 14:57     ` [PATCH] gdbserver: " Kirill Radkin
2024-02-08 16:19       ` Tom Tromey
2024-02-19 14:19         ` [PATCH v2] " Kirill Radkin

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=87edfe2qiy.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=ivan.tetyushkin@syntacore.com \
    --cc=kirill.radkin@syntacore.com \
    --cc=konstantin.vladimirov@syntacore.com \
    --cc=simark@simark.ca \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).