[lldb-dev] Patch for addressing format warnings on 32-bit

William Dillon via lldb-dev lldb-dev at lists.llvm.org
Mon Dec 28 10:32:35 PST 2015


Hi Todd,

The example I put in my last email is one of a few (maybe one more) instances where the existing code casts to 64-bit and uses PRIu64.  When I’m dabbling in existing code I try to copy the conventions that are already in place, so that’s why I went this way.  I’m happy to change it to %zu.  I was just checking about that.

- Will

> On Dec 28, 2015, at 10:24 AM, Todd Fiala <todd.fiala at gmail.com> wrote:
> 
> Hi William,
> 
> It looks like just the PRIx64/PRIu64 bits are needed from a visual inspection.  The source variables that are printed from already are 64-bit always, aren't they?  If they're not but they should be, that seems like the real underlying problem rather than needing to cast.
> 
> What kind of warning are you seeing if you just replace the % format specifier?
> 
> Thanks!
> 
> -Todd
> 
> On Sun, Dec 27, 2015 at 12:32 PM, William Dillon via lldb-dev <lldb-dev at lists.llvm.org <mailto:lldb-dev at lists.llvm.org>> wrote:
> > Message: 1
> > Date: Sat, 26 Dec 2015 21:15:53 +0100
> > From: Joerg Sonnenberger via lldb-dev <lldb-dev at lists.llvm.org <mailto:lldb-dev at lists.llvm.org>>
> > To: lldb-dev at lists.llvm.org <mailto:lldb-dev at lists.llvm.org>
> > Subject: Re: [lldb-dev] Patch for addressing format warnings on 32-bit
> > Message-ID: <20151226201553.GB14119 at britannica.bec.de <mailto:20151226201553.GB14119 at britannica.bec.de>>
> > Content-Type: text/plain; charset=utf-8
> >
> > On Fri, Dec 25, 2015 at 06:34:09PM -0800, William Dillon via lldb-dev wrote:
> >> There are a handful of -Wformat warnings on 32-bit platforms.
> >> I addressed all those that I’ve seen while working on Swift.
> >> Let me know if the git diff format is inappropriate for this.
> >
> > Don't cast size_t to uint64_t, format it with %zu directly.
> >
> > Joerg
> >
> 
> I can go ahead and do that, but I wonder whether there should be two different ways of handling this, even on the same line.  For example:
> 
> -            error.SetErrorStringWithFormat ("SoftwareBreakpointr::%s addr=0x%" PRIx64 ": tried to read %lu bytes but only read %" PRIu64, __FUNCTION__, m_addr, m_opcode_size, (uint64_t)bytes_read);
> +            error.SetErrorStringWithFormat ("SoftwareBreakpointr::%s addr=0x%" PRIx64 ": tried to read %" PRIu64 " bytes but only read %" PRIu64, __FUNCTION__, m_addr, (uint64_t)m_opcode_size, (uint64_t)bytes_read);
> 
> - Will
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org <mailto:lldb-dev at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev>
> 
> 
> 
> -- 
> -Todd

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20151228/a12bc7b0/attachment-0001.html>


More information about the lldb-dev mailing list