Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: nick clifton <nickc@redhat.com>
To: Pierre Muller <pierre.muller@ics-cnrs.unistra.fr>,
	       "'Pedro Alves'" <palves@redhat.com>,
	       "'asmwarrior'" <asmwarrior@gmail.com>
Cc: "'GDB Development'" <gdb@sourceware.org>,
	       "'Binutils Development'" <binutils@sourceware.org>
Subject: Re: [RFC-v2] BFD MinGW/Cygwin build error in bfd/peiXXgen.c
Date: Thu, 19 Dec 2013 12:41:00 -0000	[thread overview]
Message-ID: <52B2E8C4.3080208@redhat.com> (raw)
In-Reply-To: <006c01cefcaf$bec215b0$3c464110$@muller@ics-cnrs.unistra.fr>

Hi Pierre,

>    2) In GDB coding rules, we are not allowed to mix code and declaration.
> The declaration of res after handling the ! is_name part
> does not follow this rule.
>    Isn't that rule also used for Binutils project?

Doh - this is my bad.  The rule *is* followed in the Binutils project 
and I should have caught this before checking in the patch.

I blame the GCC project - ever since they switched over to using C++ I 
have been developing "bad" C coding habits.


>    I moved the declaration of astring, alen, bstring and blen to
> the start of the function. It does introduce a penalty, in the sense that
> those variables are set even though this is not useful if is_name is false.

I do not see this as a problem.  I am much more interested in clean code 
than in highly optimized, but harder to read code.


> Another silly coding style question: Should there by a space
> between the address operator "&" and the variable or expression following?

*sigh*  There is no strict rule on this subject.  Most people omit the 
space, I include it.  I feel that since we separate other operators from 
their arguments we should do the same with &.  I feel the same way about 
the asterisk operator too, but not many people agree with me on that one 
either.


>    3) I was wondering why the Windows case started at astring + 2,
> but I couldn't find any valid reason, so that I changed it to
> compare the strings from the first position.

Doh - I was confused by the length field which I thought was included in 
my string pointer.


>    Finally, I also have a question regarding the codepage field.
> According to Windows PE resources can use any codepage.
> Is the new code restricted to UNICODE only?
> If not, shouldn't the rsrc_cmp code also depend on whether
> 16-bit Windows UNICODE is used or any other page code?

I have no idea. :-(  I am not an expert on this subject.  According to 
the "Microsoft Portable Executable and Common Object File Format 
Specification Revision 8.3 – February 6, 2013" which has been my guide 
for this work, the codepage field is:

    The code page that is used to decode code point values
    within the resource data. Typically, the code page would be
    the Unicode code page.

But Resource Directory Strings are:

   Offset  Size    Field    Description
   0       2       Length   The size of the string, not including length
                            field itself.

   2      variable Unicode  The variable-length Unicode string data,
                   String   word-aligned.

Ie - the strings are explicitly encoded in Unicode.  I think that the 
codepage field in a resource entry only applies to non-resource-string data.


> 2013-12-19  Pierre Muller  <muller@sourceware.org>
>
> 	peXXigen.c (u16_mbtouc): Avoid unused function warning by excluding if
> 	__CYGWIN__ or __MINGW32__ macro is defined.
> 	(rsrc_cmp): Fix Windows host version and version without wchar header.
> 	[__CYGWIN__, __MINGW32__]: Introduce rsrccmp macro.

Thanks - I have applied this patch.

Cheers
   Nick


  reply	other threads:[~2013-12-19 12:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-18  9:54 GDB MinGW build error: implicit declaration of function 'wcsncasecmp' asmwarrior
2013-12-18  9:58 ` asmwarrior
2013-12-18 10:06 ` BFD " Pedro Alves
2013-12-18 12:50   ` asmwarrior
2013-12-18 15:47     ` Eli Zaretskii
2013-12-18 13:03   ` [RFC] BFD MinGW/Cygwin build error in bfd/peiXXgen.c Pierre Muller
2013-12-18 17:52     ` nick clifton
2013-12-19 11:45       ` [RFC-v2] " Pierre Muller
2013-12-19 12:41         ` nick clifton [this message]
2013-12-19 13:02           ` Mark Kettenis
2013-12-19 13:18           ` Pierre Muller
2013-12-19 15:13             ` nick clifton
     [not found]   ` <52b19d01.22cbc20a.69b0.ffffb29eSMTPIN_ADDED_BROKEN@mx.google.com>
2013-12-18 13:25     ` [RFC] " asmwarrior
     [not found]   ` <52b19d19.0850420a.7b6a.52dcSMTPIN_ADDED_BROKEN@mx.google.com>
2013-12-18 17:56     ` Pedro Alves
2013-12-19 11:15       ` nick clifton
2013-12-18 15:35 ` GDB MinGW build error: implicit declaration of function 'wcsncasecmp' Eli Zaretskii

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=52B2E8C4.3080208@redhat.com \
    --to=nickc@redhat.com \
    --cc=asmwarrior@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=gdb@sourceware.org \
    --cc=palves@redhat.com \
    --cc=pierre.muller@ics-cnrs.unistra.fr \
    /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