public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: Fangrui Song <maskray@google.com>
Cc: Simon Marchi <simon.marchi@polymtl.ca>,
	Jan Beulich <jbeulich@suse.com>, Nick Clifton <nickc@redhat.com>,
	binutils@sourceware.org, gdb-patches@sourceware.org
Subject: Re: [PATCH v3] binutils, gdb: support zstd compressed debug sections
Date: Mon, 26 Sep 2022 23:00:15 +0930	[thread overview]
Message-ID: <YzGpZ2PtJPeYt33n@squeak.grove.modra.org> (raw)
In-Reply-To: <20220926072027.o6g6f33hximpe7y3@google.com>

On Mon, Sep 26, 2022 at 12:20:27AM -0700, Fangrui Song wrote:
> On 2022-09-26, Alan Modra wrote:
> > Better to avoid the need..
> > 
> > binutils/
> > 	* configure.ac (msgpack): Use "AS_IF" rather than "if".
> > 	* configure: Regenerate.
> > ld/
> > 	* configure.ac (jansson): Use "AS_IF" rather than "if".
> > 	* configure: Regenerate.
> > 
> 
> Thanks.  I've changed the zstd patch to use AS_IF, too.

It probably wasn't necessary inside AC_DEFUN, but won't hurt either.

> BTW: I think the `!= xno` trick for ancient shells is not needed.  `!=
> no` is used many times in binutils-gdb.

Quite possibly true nowadays.  I'm not going to be the one that
removes them all.  :-)

Your patch looks OK to me, apart from a few formatting nits.  Here are
two examples:

> @@ -150,9 +163,10 @@ bfd_compress_section_contents (bfd *abfd, sec_ptr sec,
>        sec->size = orig_uncompressed_size;
>        if (decompress)
>  	{
> -	  if (!decompress_contents (uncompressed_buffer
> -				    + orig_compression_header_size,
> -				    zlib_size, buffer, buffer_size))
> +	  if (!decompress_contents (
> +		  sec->compress_status == DECOMPRESS_SECTION_ZSTD,
> +		  uncompressed_buffer + orig_compression_header_size,
> +		  zlib_size, buffer, buffer_size))
>  	    {
>  	      bfd_set_error (bfd_error_bad_value);
>  	      bfd_release (abfd, buffer);

One of the formatting guidelines in
https://www.gnu.org/prep/standards/html_node/Formatting.html#Formatting
talks about emacs indenting of code.  The above looks reasonable with
your indenting by hand, but auto-indent will turn it into

	  if (!decompress_contents (
				    sec->compress_status == DECOMPRESS_SECTION_ZSTD,
				    uncompressed_buffer + orig_compression_header_size,
				    zlib_size, buffer, buffer_size))

lining up function args with the open parenthesis.  Inserting a couple
of temporary vars is the nicest solution to keeping line length
manageable.

	  bool is_z = sec->compress_status == DECOMPRESS_SECTION_ZSTD;
	  bfd_byte *p = uncompressed_buffer + orig_compression_header_size;
	  if (!decompress_contents (is_z, p, zlib_size, buffer, buffer_size))

> @@ -569,7 +604,8 @@ bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec)
>    sec->compressed_size = sec->size;
>    sec->size = uncompressed_size;
>    bfd_set_section_alignment (sec, uncompressed_alignment_power);
> -  sec->compress_status = DECOMPRESS_SECTION_SIZED;
> +  sec->compress_status = ch_type == ELFCOMPRESS_ZSTD ? DECOMPRESS_SECTION_ZSTD
> +						     : DECOMPRESS_SECTION_ZLIB;
>  
>    return true;
>  }

The same emacs auto-indent will ruin the above.  Write

  sec->compress_status = (ch_type == ELFCOMPRESS_ZSTD
			  ? DECOMPRESS_SECTION_ZSTD : DECOMPRESS_SECTION_ZLIB);

with unnecessary parentheses to guide indentation.
OK to commit with those things fixed.

-- 
Alan Modra
Australia Development Lab, IBM

  reply	other threads:[~2022-09-26 13:30 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-23  4:08 Fangrui Song
2022-09-23 14:32 ` Simon Marchi
2022-09-26  5:12   ` Alan Modra
2022-09-26  7:20     ` Fangrui Song
2022-09-26 13:30       ` Alan Modra [this message]
2022-09-26 14:08     ` Simon Marchi
2022-09-27  0:33       ` Alan Modra
2022-09-23 15:45 ` Nick Clifton
2022-09-23 15:58   ` Simon Marchi
2022-09-23 18:20     ` Fangrui Song
2022-09-23 18:57       ` Simon Marchi
2022-09-23 20:34         ` Fangrui Song
2022-09-24  5:43           ` Eli Zaretskii
2022-09-24  6:53 ` Enze Li
2022-09-24  7:13   ` Fangrui Song
2022-09-27 18:06     ` Tom Tromey
2022-09-27 18:08 ` Tom Tromey
2022-09-27 18:53   ` Fangrui Song
2022-09-28 11:52     ` [PATCH] Fix GDB build: ELF support check & -lzstd (was: Re: [PATCH v3] binutils, gdb: support zstd compressed debug sections) Pedro Alves
2022-09-28 19:00       ` Simon Marchi
2022-09-28 19:27         ` Pedro Alves
2022-09-28 19:30         ` Fangrui Song
2022-09-29 18:30           ` Pedro Alves
2022-09-29 11:43 ` [PATCH v3] binutils, gdb: support zstd compressed debug sections Martin Liška
2022-09-29 20:17   ` Fangrui Song

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=YzGpZ2PtJPeYt33n@squeak.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=gdb-patches@sourceware.org \
    --cc=jbeulich@suse.com \
    --cc=maskray@google.com \
    --cc=nickc@redhat.com \
    --cc=simon.marchi@polymtl.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).