Re: [Xen-devel] [PATCH v2] libelf: drop pointless uses of __FUNCTION__
Jan Beulich writes ("[PATCH v2] libelf: drop pointless uses of __FUNCTION__"): > Non-debugging message text should be (and is in the cases here, albeit > often only with the addition of an ELF: prefix) distinguishable without > also logging function names. > > In the messages touched at once use %#x (or variants thereof) in favor > of 0x%x. > --- > v2: Add a missing ELF: prefix. Further disambiguate note related > messages. Also take care of one instance of __func__. Acked-by: Ian JacksonThanks, Ian. ___ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel
Re: [Xen-devel] [PATCH v2] libelf: drop pointless uses of __FUNCTION__
>>> On 07.09.16 at 09:59,wrote: > Non-debugging message text should be (and is in the cases here, albeit > often only with the addition of an ELF: prefix) distinguishable without > also logging function names. > > In the messages touched at once use %#x (or variants thereof) in favor > of 0x%x. (Obviously) Signed-off-by: Jan Beulich > --- > v2: Add a missing ELF: prefix. Further disambiguate note related > messages. Also take care of one instance of __func__. > > --- a/xen/common/libelf/libelf-dominfo.c > +++ b/xen/common/libelf/libelf-dominfo.c > @@ -131,8 +131,7 @@ elf_errorstatus elf_xen_parse_note(struc > if ( (type >= sizeof(note_desc) / sizeof(note_desc[0])) || > (note_desc[type].name == NULL) ) > { > -elf_msg(elf, "%s: unknown xen elf note (0x%x)\n", > -__FUNCTION__, type); > +elf_msg(elf, "ELF: note: unknown (%#x)\n", type); > return 0; > } > > @@ -142,16 +141,14 @@ elf_errorstatus elf_xen_parse_note(struc > if (str == NULL) > /* elf_strval will mark elf broken if it fails so no need to > log */ > return 0; > -elf_msg(elf, "%s: %s = \"%s\"\n", __FUNCTION__, > -note_desc[type].name, str); > +elf_msg(elf, "ELF: note: %s = \"%s\"\n", note_desc[type].name, > str); > parms->elf_notes[type].type = XEN_ENT_STR; > parms->elf_notes[type].data.str = str; > } > else > { > val = elf_note_numeric(elf, note); > -elf_msg(elf, "%s: %s = 0x%" PRIx64 "\n", __FUNCTION__, > -note_desc[type].name, val); > +elf_msg(elf, "ELF: note: %s = %#" PRIx64 "\n", > note_desc[type].name, val); > parms->elf_notes[type].type = XEN_ENT_LONG; > parms->elf_notes[type].data.num = val; > } > @@ -310,7 +307,7 @@ elf_errorstatus elf_xen_parse_guest_info > } > name[len] = STAR(h); > } > -elf_msg(elf, "%s: %s=\"%s\"\n", __FUNCTION__, name, value); > +elf_msg(elf, "ELF: %s=\"%s\"\n", name, value); > > /* strings */ > if ( !strcmp(name, "LOADER") ) > @@ -363,9 +360,8 @@ static elf_errorstatus elf_xen_note_chec > unsigned machine = elf_uval(elf, elf->ehdr, e_machine); > if ( (machine == EM_386) || (machine == EM_X86_64) ) > { > -elf_err(elf, "%s: ERROR: Not a Xen-ELF image: " > -"No ELF notes or '__xen_guest' section found.\n", > -__FUNCTION__); > +elf_err(elf, "ERROR: Not a Xen-ELF image: " > +"No ELF notes or '__xen_guest' section found\n"); > return -1; > } > return 0; > @@ -373,7 +369,7 @@ static elf_errorstatus elf_xen_note_chec > > if ( elf_uval(elf, elf->ehdr, e_machine) == EM_ARM ) > { > - elf_msg(elf, "%s: Not bothering with notes on ARM\n", > __FUNCTION__); > + elf_msg(elf, "ELF: Not bothering with notes on ARM\n"); > return 0; > } > > @@ -383,9 +379,10 @@ static elf_errorstatus elf_xen_note_chec > ((strlen(parms->guest_os) == 0) || >strncmp(parms->guest_os, "linux", 5)) ) > { > -elf_err(elf, "%s: ERROR: Will only load images built for the generic > " > -"loader or Linux images (Not '%.*s' and '%.*s')\n", > -__FUNCTION__, (int)sizeof(parms->loader), parms->loader, > +elf_err(elf, > +"ERROR: Will only load images built for the generic loader > or Linux images" > +" (Not '%.*s' and '%.*s')\n", > +(int)sizeof(parms->loader), parms->loader, > (int)sizeof(parms->guest_os), parms->guest_os); > return -1; > } > @@ -393,8 +390,8 @@ static elf_errorstatus elf_xen_note_chec > if ( (strlen(parms->xen_ver) == 0) || > strncmp(parms->xen_ver, "xen-3.0", 7) ) > { > -elf_err(elf, "%s: ERROR: Xen will only load images built " > -"for Xen v3.0 (Not '%.*s')\n", __FUNCTION__, > +elf_err(elf, "ERROR: Xen will only load images built for Xen v3.0 " > +"(Not '%.*s')\n", > (int)sizeof(parms->xen_ver), parms->xen_ver); > return -1; > } > @@ -409,8 +406,7 @@ static elf_errorstatus elf_xen_addr_calc > if ( (parms->elf_paddr_offset != UNSET_ADDR) && > (parms->virt_base == UNSET_ADDR) ) > { > -elf_err(elf, "%s: ERROR: ELF_PADDR_OFFSET set, VIRT_BASE unset\n", > -__FUNCTION__); > +elf_err(elf, "ERROR: ELF_PADDR_OFFSET set, VIRT_BASE unset\n"); > return -1; > } > > @@ -418,8 +414,8 @@ static elf_errorstatus elf_xen_addr_calc > if ( parms->virt_base == UNSET_ADDR ) > { > parms->virt_base = 0; > -elf_msg(elf, "%s: VIRT_BASE unset, using 0x%" PRIx64 "\n", > -__FUNCTION__,
[Xen-devel] [PATCH v2] libelf: drop pointless uses of __FUNCTION__
Non-debugging message text should be (and is in the cases here, albeit often only with the addition of an ELF: prefix) distinguishable without also logging function names. In the messages touched at once use %#x (or variants thereof) in favor of 0x%x. --- v2: Add a missing ELF: prefix. Further disambiguate note related messages. Also take care of one instance of __func__. --- a/xen/common/libelf/libelf-dominfo.c +++ b/xen/common/libelf/libelf-dominfo.c @@ -131,8 +131,7 @@ elf_errorstatus elf_xen_parse_note(struc if ( (type >= sizeof(note_desc) / sizeof(note_desc[0])) || (note_desc[type].name == NULL) ) { -elf_msg(elf, "%s: unknown xen elf note (0x%x)\n", -__FUNCTION__, type); +elf_msg(elf, "ELF: note: unknown (%#x)\n", type); return 0; } @@ -142,16 +141,14 @@ elf_errorstatus elf_xen_parse_note(struc if (str == NULL) /* elf_strval will mark elf broken if it fails so no need to log */ return 0; -elf_msg(elf, "%s: %s = \"%s\"\n", __FUNCTION__, -note_desc[type].name, str); +elf_msg(elf, "ELF: note: %s = \"%s\"\n", note_desc[type].name, str); parms->elf_notes[type].type = XEN_ENT_STR; parms->elf_notes[type].data.str = str; } else { val = elf_note_numeric(elf, note); -elf_msg(elf, "%s: %s = 0x%" PRIx64 "\n", __FUNCTION__, -note_desc[type].name, val); +elf_msg(elf, "ELF: note: %s = %#" PRIx64 "\n", note_desc[type].name, val); parms->elf_notes[type].type = XEN_ENT_LONG; parms->elf_notes[type].data.num = val; } @@ -310,7 +307,7 @@ elf_errorstatus elf_xen_parse_guest_info } name[len] = STAR(h); } -elf_msg(elf, "%s: %s=\"%s\"\n", __FUNCTION__, name, value); +elf_msg(elf, "ELF: %s=\"%s\"\n", name, value); /* strings */ if ( !strcmp(name, "LOADER") ) @@ -363,9 +360,8 @@ static elf_errorstatus elf_xen_note_chec unsigned machine = elf_uval(elf, elf->ehdr, e_machine); if ( (machine == EM_386) || (machine == EM_X86_64) ) { -elf_err(elf, "%s: ERROR: Not a Xen-ELF image: " -"No ELF notes or '__xen_guest' section found.\n", -__FUNCTION__); +elf_err(elf, "ERROR: Not a Xen-ELF image: " +"No ELF notes or '__xen_guest' section found\n"); return -1; } return 0; @@ -373,7 +369,7 @@ static elf_errorstatus elf_xen_note_chec if ( elf_uval(elf, elf->ehdr, e_machine) == EM_ARM ) { - elf_msg(elf, "%s: Not bothering with notes on ARM\n", __FUNCTION__); + elf_msg(elf, "ELF: Not bothering with notes on ARM\n"); return 0; } @@ -383,9 +379,10 @@ static elf_errorstatus elf_xen_note_chec ((strlen(parms->guest_os) == 0) || strncmp(parms->guest_os, "linux", 5)) ) { -elf_err(elf, "%s: ERROR: Will only load images built for the generic " -"loader or Linux images (Not '%.*s' and '%.*s')\n", -__FUNCTION__, (int)sizeof(parms->loader), parms->loader, +elf_err(elf, +"ERROR: Will only load images built for the generic loader or Linux images" +" (Not '%.*s' and '%.*s')\n", +(int)sizeof(parms->loader), parms->loader, (int)sizeof(parms->guest_os), parms->guest_os); return -1; } @@ -393,8 +390,8 @@ static elf_errorstatus elf_xen_note_chec if ( (strlen(parms->xen_ver) == 0) || strncmp(parms->xen_ver, "xen-3.0", 7) ) { -elf_err(elf, "%s: ERROR: Xen will only load images built " -"for Xen v3.0 (Not '%.*s')\n", __FUNCTION__, +elf_err(elf, "ERROR: Xen will only load images built for Xen v3.0 " +"(Not '%.*s')\n", (int)sizeof(parms->xen_ver), parms->xen_ver); return -1; } @@ -409,8 +406,7 @@ static elf_errorstatus elf_xen_addr_calc if ( (parms->elf_paddr_offset != UNSET_ADDR) && (parms->virt_base == UNSET_ADDR) ) { -elf_err(elf, "%s: ERROR: ELF_PADDR_OFFSET set, VIRT_BASE unset\n", -__FUNCTION__); +elf_err(elf, "ERROR: ELF_PADDR_OFFSET set, VIRT_BASE unset\n"); return -1; } @@ -418,8 +414,8 @@ static elf_errorstatus elf_xen_addr_calc if ( parms->virt_base == UNSET_ADDR ) { parms->virt_base = 0; -elf_msg(elf, "%s: VIRT_BASE unset, using 0x%" PRIx64 "\n", -__FUNCTION__, parms->virt_base); +elf_msg(elf, "ELF: VIRT_BASE unset, using %#" PRIx64 "\n", +parms->virt_base); } /* @@ -437,8 +433,8 @@ static elf_errorstatus elf_xen_addr_calc parms->elf_paddr_offset = 0; else parms->elf_paddr_offset = parms->virt_base; -elf_msg(elf, "%s: ELF_PADDR_OFFSET