This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v3] ari, btrace: avoid unsigned long long
- From: Pedro Alves <palves at redhat dot com>
- To: Markus Metzger <markus dot t dot metzger at intel dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 14 Jul 2015 16:12:48 +0100
- Subject: Re: [PATCH v3] ari, btrace: avoid unsigned long long
- Authentication-results: sourceware.org; auth=none
- References: <1436798835-13022-1-git-send-email-markus dot t dot metzger at intel dot com>
On 07/13/2015 03:47 PM, Markus Metzger wrote:
> diff --git a/gdb/common/btrace-common.c b/gdb/common/btrace-common.c
> index 95193eb..9d6c4a7 100644
> --- a/gdb/common/btrace-common.c
> +++ b/gdb/common/btrace-common.c
> @@ -155,10 +155,10 @@ btrace_data_append (struct btrace_data *dst,
> dst->variant.pt.size = 0;
>
> /* fall-through. */
> - case BTRACE_FORMAT_BTS:
> + case BTRACE_FORMAT_PT:
Looks like an unrelated change that should be pushed separately.
> {
> gdb_byte *data;
> - unsigned long size;
> + size_t size;
>
> tinfo = xzalloc (sizeof (*tinfo));
> @@ -674,28 +676,36 @@ linux_enable_bts (ptid_t ptid, const struct btrace_config_bts *conf)
> goto err_out;
>
> /* Convert the requested size in bytes to pages (rounding up). */
> - pages = (((unsigned long long) conf->size) + PAGE_SIZE - 1) / PAGE_SIZE;
> + pages = (size_t) conf->size / PAGE_SIZE
> + + ((conf->size % PAGE_SIZE) == 0 ? 0 : 1);
Per, http://www.gnu.org/prep/standards/standards.html#Formatting
wrap with ()s so that the second line aligns correctly:
pages = ((size_t) conf->size / PAGE_SIZE
+ ((conf->size % PAGE_SIZE) == 0 ? 0 : 1));
> /* Convert the requested size in bytes to pages (rounding up). */
> - pages = (((unsigned long long) conf->size) + PAGE_SIZE - 1) / PAGE_SIZE;
> + pages = (size_t) conf->size / PAGE_SIZE
> + + ((conf->size % PAGE_SIZE) == 0 ? 0 : 1);
Likewise.
Otherwise looks good to me.
Thanks,
Pedro Alves