From: Indu Bhagat <ibhagat@sourceware.org>
To: bfd-cvs@sourceware.org, gdb-cvs@sourceware.org
Subject: [binutils-gdb] libsframe: avoid using magic number
Date: Thu, 1 Jun 2023 16:55:19 +0000 (GMT) [thread overview]
Message-ID: <20230601165519.45316385770B@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d987df5c95340a8b41b23d68ad6a8f9f33485835
commit d987df5c95340a8b41b23d68ad6a8f9f33485835
Author: Indu Bhagat <indu.bhagat@oracle.com>
Date: Thu Jun 1 09:41:04 2023 -0700
libsframe: avoid using magic number
Define a new constant for the maximum number of stack offsets handled in
libsframe, and use it. Note that the SFrame format does not define such
a constant (limit). This is an implmentation-defined constant in
libsframe.
include/
* sframe-api.h (MAX_NUM_STACK_OFFSETS): New definition.
libsframe/
* sframe.c (sframe_fre_sanity_check_p): Use it.
Diff:
---
include/sframe-api.h | 5 ++++-
libsframe/sframe.c | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/include/sframe-api.h b/include/sframe-api.h
index 405e30c27e8..3245bc8ac90 100644
--- a/include/sframe-api.h
+++ b/include/sframe-api.h
@@ -31,7 +31,10 @@ extern "C"
typedef struct sframe_decoder_ctx sframe_decoder_ctx;
typedef struct sframe_encoder_ctx sframe_encoder_ctx;
-#define MAX_OFFSET_BYTES (SFRAME_FRE_OFFSET_4B * 2 * 3)
+#define MAX_NUM_STACK_OFFSETS 3
+
+#define MAX_OFFSET_BYTES \
+ ((SFRAME_FRE_OFFSET_4B * 2 * MAX_NUM_STACK_OFFSETS))
/* User interfacing SFrame Row Entry.
An abstraction provided by libsframe so the consumer is decoupled from
diff --git a/libsframe/sframe.c b/libsframe/sframe.c
index 97b49106e39..a97c64f7a9b 100644
--- a/libsframe/sframe.c
+++ b/libsframe/sframe.c
@@ -299,7 +299,7 @@ sframe_fre_sanity_check_p (sframe_frame_row_entry *frep)
return false;
offset_cnt = sframe_fre_get_offset_count (fre_info);
- if (offset_cnt > 3)
+ if (offset_cnt > MAX_NUM_STACK_OFFSETS)
return false;
return true;
reply other threads:[~2023-06-01 16:55 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=20230601165519.45316385770B@sourceware.org \
--to=ibhagat@sourceware.org \
--cc=bfd-cvs@sourceware.org \
--cc=gdb-cvs@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).