Message ID | 20181127121724.19755-3-sw@weilnetz.de |
---|---|
State | New |
Headers | show |
Series | Fix disas/nanomips | expand |
On Tue, Nov 27, 2018 at 1:19 PM Stefan Weil <sw@weilnetz.de> wrote: > > Signed-off-by: Stefan Weil <sw@weilnetz.de> > --- > disas/nanomips.cpp | 18 +++++++++++------- > 1 file changed, 11 insertions(+), 7 deletions(-) > Hi, Stefan, My plan is to accept this patch plus (in the same patch) following changes in nanomips.h: This code: typedef unsigned short uint16; typedef unsigned int uint32; typedef long long int64; typedef unsigned long long uint64; namespace img { typedef unsigned long long address; } should become: typedef uint16_t uint16; typedef uint32_t uint32; typedef int64_t int64; typedef uint64_t uint64; namespace img { typedef uint64_t address; } The reason is that I would like to keep custom types. The custom types names "uint32", "int64", etc. are admittedly too generic, but that will change in further development, and it looks do not bother any compiler so far. This means that patch 1/1 will not be applied. There is no need for respin, I will do the corrections while integrating pull request. Please let me know if you object over this. Thanks again for bringing all these issues! Aleksandar > diff --git a/disas/nanomips.cpp b/disas/nanomips.cpp > index 4c3cfceaba..a3f69348b3 100644 > --- a/disas/nanomips.cpp > +++ b/disas/nanomips.cpp > @@ -284,7 +284,8 @@ uint64_t NMD::renumber_registers(uint64_t index, uint64_t *register_list, > } > > throw std::runtime_error(img::format( > - "Invalid register mapping index %d, size of list = %d", > + "Invalid register mapping index %" PRIu64 > + ", size of list = %zu", > index, register_list_size)); > } > > @@ -501,7 +502,8 @@ std::string NMD::GPR(uint64_t reg) > return gpr_reg[reg]; > } > > - throw std::runtime_error(img::format("Invalid GPR register index %d", reg)); > + throw std::runtime_error(img::format("Invalid GPR register index %" PRIu64, > + reg)); > } > > > @@ -518,7 +520,8 @@ std::string NMD::FPR(uint64_t reg) > return fpr_reg[reg]; > } > > - throw std::runtime_error(img::format("Invalid FPR register index %d", reg)); > + throw std::runtime_error(img::format("Invalid FPR register index %" PRIu64, > + reg)); > } > > > @@ -532,26 +535,27 @@ std::string NMD::AC(uint64_t reg) > return ac_reg[reg]; > } > > - throw std::runtime_error(img::format("Invalid AC register index %d", reg)); > + throw std::runtime_error(img::format("Invalid AC register index %" PRIu64, > + reg)); > } > > > std::string NMD::IMMEDIATE(uint64_t value) > { > - return img::format("0x%x", value); > + return img::format("0x%" PRIx64, value); > } > > > std::string NMD::IMMEDIATE(int64_t value) > { > - return img::format("%d", value); > + return img::format("%" PRId64, value); > } > > > std::string NMD::CPR(uint64_t reg) > { > /* needs more work */ > - return img::format("CP%d", reg); > + return img::format("CP%" PRIu64, reg); > } > > > -- > 2.11.0 > >
On 23.12.18 18:10, Aleksandar Markovic wrote: > Hi, Stefan, > > My plan is to accept this patch plus (in the same patch) following > changes in nanomips.h: > > This code: > > typedef unsigned short uint16; > typedef unsigned int uint32; > typedef long long int64; > typedef unsigned long long uint64; > > namespace img > { > typedef unsigned long long address; > } > > should become: > > typedef uint16_t uint16; > typedef uint32_t uint32; > typedef int64_t int64; > typedef uint64_t uint64; > > namespace img > { > typedef uint64_t address; > } > > The reason is that I would like to keep custom types. The custom types > names "uint32", "int64", etc. are admittedly too generic, but that > will change in further development, and it looks do not bother any > compiler so far. This means that patch 1/1 will not be applied. I must admit that I don't understand the reason for keeping the custom types (many software projects work very well with the POSIX types), but the more important thing is to get the right format strings, and your approach will work for that. It's also good that you address the definition of the "address" data type. Maybe using "typedef uintptr_t address" could also be used (reducing the memory use for 32 bit systems). Stefan > There is no need for respin, I will do the corrections while > integrating pull request. > > Please let me know if you object over this. > > Thanks again for bringing all these issues! > > Aleksandar
diff --git a/disas/nanomips.cpp b/disas/nanomips.cpp index 4c3cfceaba..a3f69348b3 100644 --- a/disas/nanomips.cpp +++ b/disas/nanomips.cpp @@ -284,7 +284,8 @@ uint64_t NMD::renumber_registers(uint64_t index, uint64_t *register_list, } throw std::runtime_error(img::format( - "Invalid register mapping index %d, size of list = %d", + "Invalid register mapping index %" PRIu64 + ", size of list = %zu", index, register_list_size)); } @@ -501,7 +502,8 @@ std::string NMD::GPR(uint64_t reg) return gpr_reg[reg]; } - throw std::runtime_error(img::format("Invalid GPR register index %d", reg)); + throw std::runtime_error(img::format("Invalid GPR register index %" PRIu64, + reg)); } @@ -518,7 +520,8 @@ std::string NMD::FPR(uint64_t reg) return fpr_reg[reg]; } - throw std::runtime_error(img::format("Invalid FPR register index %d", reg)); + throw std::runtime_error(img::format("Invalid FPR register index %" PRIu64, + reg)); } @@ -532,26 +535,27 @@ std::string NMD::AC(uint64_t reg) return ac_reg[reg]; } - throw std::runtime_error(img::format("Invalid AC register index %d", reg)); + throw std::runtime_error(img::format("Invalid AC register index %" PRIu64, + reg)); } std::string NMD::IMMEDIATE(uint64_t value) { - return img::format("0x%x", value); + return img::format("0x%" PRIx64, value); } std::string NMD::IMMEDIATE(int64_t value) { - return img::format("%d", value); + return img::format("%" PRId64, value); } std::string NMD::CPR(uint64_t reg) { /* needs more work */ - return img::format("CP%d", reg); + return img::format("CP%" PRIu64, reg); }
Signed-off-by: Stefan Weil <sw@weilnetz.de> --- disas/nanomips.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)