From: tip-bot for Steven Rostedt <srostedt@redhat.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
rostedt@goodmis.org, srostedt@redhat.com, jreiser@bitwagon.com,
tglx@linutronix.de
Subject: [tip:perf/core] ftrace/trivial: Clean up recordmcount.c to use Linux style comparisons
Date: Thu, 16 Jun 2011 14:04:20 GMT [thread overview]
Message-ID: <tip-c6fece27dfa46abc8c4b87d94a8c2f8cd6c5d8b1@git.kernel.org> (raw)
In-Reply-To: <20110421023737.290712238@goodmis.org>
Commit-ID: c6fece27dfa46abc8c4b87d94a8c2f8cd6c5d8b1
Gitweb: http://git.kernel.org/tip/c6fece27dfa46abc8c4b87d94a8c2f8cd6c5d8b1
Author: Steven Rostedt <srostedt@redhat.com>
AuthorDate: Wed, 6 Apr 2011 13:21:17 -0400
Committer: Steven Rostedt <rostedt@goodmis.org>
CommitDate: Tue, 17 May 2011 10:41:30 -0400
ftrace/trivial: Clean up recordmcount.c to use Linux style comparisons
The Linux ftrace subsystem style for comparing is:
var == 1
var > 0
and not:
1 == var
0 < var
It is considered that Linux developers are smart enough not to do the
if (var = 1)
mistake.
Cc: John Reiser <jreiser@bitwagon.com>
Link: http://lkml.kernel.org/r/20110421023737.290712238@goodmis.org
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
scripts/recordmcount.c | 48 ++++++++++++++++++++++++------------------------
scripts/recordmcount.h | 16 ++++++++--------
2 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
index f9f6f52..37afe0e 100644
--- a/scripts/recordmcount.c
+++ b/scripts/recordmcount.c
@@ -78,7 +78,7 @@ static off_t
ulseek(int const fd, off_t const offset, int const whence)
{
off_t const w = lseek(fd, offset, whence);
- if ((off_t)-1 == w) {
+ if (w == (off_t)-1) {
perror("lseek");
fail_file();
}
@@ -111,7 +111,7 @@ static void *
umalloc(size_t size)
{
void *const addr = malloc(size);
- if (0 == addr) {
+ if (addr == 0) {
fprintf(stderr, "malloc failed: %zu bytes\n", size);
fail_file();
}
@@ -136,7 +136,7 @@ static void *mmap_file(char const *fname)
void *addr;
fd_map = open(fname, O_RDWR);
- if (0 > fd_map || 0 > fstat(fd_map, &sb)) {
+ if (fd_map < 0 || fstat(fd_map, &sb) < 0) {
perror(fname);
fail_file();
}
@@ -147,7 +147,7 @@ static void *mmap_file(char const *fname)
addr = mmap(0, sb.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE,
fd_map, 0);
mmap_failed = 0;
- if (MAP_FAILED == addr) {
+ if (addr == MAP_FAILED) {
mmap_failed = 1;
addr = umalloc(sb.st_size);
uread(fd_map, addr, sb.st_size);
@@ -206,12 +206,12 @@ static uint32_t (*w2)(uint16_t);
static int
is_mcounted_section_name(char const *const txtname)
{
- return 0 == strcmp(".text", txtname) ||
- 0 == strcmp(".ref.text", txtname) ||
- 0 == strcmp(".sched.text", txtname) ||
- 0 == strcmp(".spinlock.text", txtname) ||
- 0 == strcmp(".irqentry.text", txtname) ||
- 0 == strcmp(".text.unlikely", txtname);
+ return strcmp(".text", txtname) == 0 ||
+ strcmp(".ref.text", txtname) == 0 ||
+ strcmp(".sched.text", txtname) == 0 ||
+ strcmp(".spinlock.text", txtname) == 0 ||
+ strcmp(".irqentry.text", txtname) == 0 ||
+ strcmp(".text.unlikely", txtname) == 0;
}
/* 32 bit and 64 bit are very similar */
@@ -270,7 +270,7 @@ do_file(char const *const fname)
fail_file();
} break;
case ELFDATA2LSB: {
- if (1 != *(unsigned char const *)&endian) {
+ if (*(unsigned char const *)&endian != 1) {
/* main() is big endian, file.o is little endian. */
w = w4rev;
w2 = w2rev;
@@ -278,7 +278,7 @@ do_file(char const *const fname)
}
} break;
case ELFDATA2MSB: {
- if (0 != *(unsigned char const *)&endian) {
+ if (*(unsigned char const *)&endian != 0) {
/* main() is little endian, file.o is big endian. */
w = w4rev;
w2 = w2rev;
@@ -286,9 +286,9 @@ do_file(char const *const fname)
}
} break;
} /* end switch */
- if (0 != memcmp(ELFMAG, ehdr->e_ident, SELFMAG)
- || ET_REL != w2(ehdr->e_type)
- || EV_CURRENT != ehdr->e_ident[EI_VERSION]) {
+ if (memcmp(ELFMAG, ehdr->e_ident, SELFMAG) != 0
+ || w2(ehdr->e_type) != ET_REL
+ || ehdr->e_ident[EI_VERSION] != EV_CURRENT) {
fprintf(stderr, "unrecognized ET_REL file %s\n", fname);
fail_file();
}
@@ -321,15 +321,15 @@ do_file(char const *const fname)
fail_file();
} break;
case ELFCLASS32: {
- if (sizeof(Elf32_Ehdr) != w2(ehdr->e_ehsize)
- || sizeof(Elf32_Shdr) != w2(ehdr->e_shentsize)) {
+ if (w2(ehdr->e_ehsize) != sizeof(Elf32_Ehdr)
+ || w2(ehdr->e_shentsize) != sizeof(Elf32_Shdr)) {
fprintf(stderr,
"unrecognized ET_REL file: %s\n", fname);
fail_file();
}
- if (EM_S390 == w2(ehdr->e_machine))
+ if (w2(ehdr->e_machine) == EM_S390)
reltype = R_390_32;
- if (EM_MIPS == w2(ehdr->e_machine)) {
+ if (w2(ehdr->e_machine) == EM_MIPS) {
reltype = R_MIPS_32;
is_fake_mcount32 = MIPS32_is_fake_mcount;
}
@@ -337,15 +337,15 @@ do_file(char const *const fname)
} break;
case ELFCLASS64: {
Elf64_Ehdr *const ghdr = (Elf64_Ehdr *)ehdr;
- if (sizeof(Elf64_Ehdr) != w2(ghdr->e_ehsize)
- || sizeof(Elf64_Shdr) != w2(ghdr->e_shentsize)) {
+ if (w2(ghdr->e_ehsize) != sizeof(Elf64_Ehdr)
+ || w2(ghdr->e_shentsize) != sizeof(Elf64_Shdr)) {
fprintf(stderr,
"unrecognized ET_REL file: %s\n", fname);
fail_file();
}
- if (EM_S390 == w2(ghdr->e_machine))
+ if (w2(ghdr->e_machine) == EM_S390)
reltype = R_390_64;
- if (EM_MIPS == w2(ghdr->e_machine)) {
+ if (w2(ghdr->e_machine) == EM_MIPS) {
reltype = R_MIPS_64;
Elf64_r_sym = MIPS64_r_sym;
Elf64_r_info = MIPS64_r_info;
@@ -371,7 +371,7 @@ main(int argc, char const *argv[])
}
/* Process each file in turn, allowing deep failure. */
- for (--argc, ++argv; 0 < argc; --argc, ++argv) {
+ for (--argc, ++argv; argc > 0; --argc, ++argv) {
int const sjval = setjmp(jmpenv);
int len;
diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h
index baf187b..ac7b330 100644
--- a/scripts/recordmcount.h
+++ b/scripts/recordmcount.h
@@ -275,12 +275,12 @@ static uint_t *sift_rel_mcount(uint_t *mlocp,
Elf_Sym const *const symp =
&sym0[Elf_r_sym(relp)];
char const *symname = &str0[w(symp->st_name)];
- char const *mcount = '_' == gpfx ? "_mcount" : "mcount";
+ char const *mcount = gpfx == '_' ? "_mcount" : "mcount";
- if ('.' == symname[0])
+ if (symname[0] == '.')
++symname; /* ppc64 hack */
- if (0 == strcmp(mcount, symname) ||
- (altmcount && 0 == strcmp(altmcount, symname)))
+ if (strcmp(mcount, symname) == 0 ||
+ (altmcount && strcmp(altmcount, symname) == 0))
mcountsym = Elf_r_sym(relp);
}
@@ -290,7 +290,7 @@ static uint_t *sift_rel_mcount(uint_t *mlocp,
mrelp->r_offset = _w(offbase
+ ((void *)mlocp - (void *)mloc0));
Elf_r_info(mrelp, recsym, reltype);
- if (sizeof(Elf_Rela) == rel_entsize) {
+ if (rel_entsize == sizeof(Elf_Rela)) {
((Elf_Rela *)mrelp)->r_addend = addend;
*mlocp++ = 0;
} else
@@ -354,12 +354,12 @@ __has_rel_mcount(Elf_Shdr const *const relhdr, /* is SHT_REL or SHT_RELA */
Elf_Shdr const *const txthdr = &shdr0[w(relhdr->sh_info)];
char const *const txtname = &shstrtab[w(txthdr->sh_name)];
- if (0 == strcmp("__mcount_loc", txtname)) {
+ if (strcmp("__mcount_loc", txtname) == 0) {
fprintf(stderr, "warning: __mcount_loc already exists: %s\n",
fname);
succeed_file();
}
- if (SHT_PROGBITS != w(txthdr->sh_type) ||
+ if (w(txthdr->sh_type) != SHT_PROGBITS ||
!is_mcounted_section_name(txtname))
return NULL;
return txtname;
@@ -370,7 +370,7 @@ static char const *has_rel_mcount(Elf_Shdr const *const relhdr,
char const *const shstrtab,
char const *const fname)
{
- if (SHT_REL != w(relhdr->sh_type) && SHT_RELA != w(relhdr->sh_type))
+ if (w(relhdr->sh_type) != SHT_REL && w(relhdr->sh_type) != SHT_RELA)
return NULL;
return __has_rel_mcount(relhdr, shdr0, shstrtab, fname);
}
next prev parent reply other threads:[~2011-06-16 14:04 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-21 2:28 [RFC][PATCH 00/11] ftrace/recordmcount: Remove useless mcount calls not being traced Steven Rostedt
2011-04-21 2:28 ` [RFC][PATCH 01/11] ftrace/trivial: Clean up recordmcount.c to use Linux style comparisons Steven Rostedt
2011-04-21 8:46 ` Alan Cox
2011-04-21 11:36 ` Steven Rostedt
2011-04-21 12:28 ` Steven Rostedt
2011-04-22 15:09 ` John Reiser
2011-04-22 15:52 ` Thiago Farina
2011-04-22 16:05 ` Steven Rostedt
2011-04-26 18:52 ` Thiago Farina
2011-04-26 19:09 ` Steven Rostedt
2011-04-22 16:13 ` Steven Rostedt
2011-04-22 17:40 ` John Reiser
2011-04-22 17:56 ` H. Peter Anvin
2011-05-18 18:31 ` [tip:perf/core] " tip-bot for Steven Rostedt
2011-06-16 14:04 ` tip-bot for Steven Rostedt [this message]
2011-04-21 2:28 ` [RFC][PATCH 02/11] ftrace/trivial: Clean up record mcount to use Linux switch style Steven Rostedt
2011-05-18 18:31 ` [tip:perf/core] " tip-bot for Steven Rostedt
2011-06-16 14:04 ` tip-bot for Steven Rostedt
2011-04-21 2:28 ` [RFC][PATCH 03/11] ftrace: Add .kprobe.text section to whitelist for recordmcount.c Steven Rostedt
2011-05-18 18:32 ` [tip:perf/core] " tip-bot for Steven Rostedt
2011-06-16 14:05 ` tip-bot for Steven Rostedt
2011-04-21 2:28 ` [RFC][PATCH 04/11] ftrace/recordmcount: Modify only executable sections Steven Rostedt
2011-05-18 18:32 ` [tip:perf/core] " tip-bot for Steven Rostedt
2011-06-16 14:05 ` tip-bot for Steven Rostedt
2011-04-21 2:28 ` [RFC][PATCH 05/11] ftrace/recordmcount: Make ignored mcount calls into nops at compile time Steven Rostedt
2011-05-18 18:32 ` [tip:perf/core] " tip-bot for Steven Rostedt
2011-06-16 14:05 ` tip-bot for Steven Rostedt
2011-04-21 2:28 ` [RFC][PATCH 06/11] ftrace/recordmcount: Add warning logic to warn on mcount not recorded Steven Rostedt
2011-05-18 18:33 ` [tip:perf/core] " tip-bot for Steven Rostedt
2011-06-16 14:06 ` tip-bot for Steven Rostedt
2011-04-21 2:28 ` [RFC][PATCH 07/11] kbuild/recordmcount: Add RECORDMCOUNT_WARN to warn about mcount callers Steven Rostedt
2011-04-21 2:40 ` Steven Rostedt
2011-04-21 20:40 ` Michal Marek
2011-04-26 19:08 ` Steven Rostedt
2011-05-18 18:33 ` [tip:perf/core] " tip-bot for Steven Rostedt
2011-06-16 14:06 ` tip-bot for Steven Rostedt
2011-04-21 2:28 ` [RFC][PATCH 08/11] ftrace: Avoid recording mcount on .init sections directly Steven Rostedt
2011-05-18 18:34 ` [tip:perf/core] " tip-bot for Steven Rostedt
2011-06-16 14:07 ` tip-bot for Steven Rostedt
2011-04-21 2:28 ` [RFC][PATCH 09/11] ftrace/x86: Do not trace .discard.text section Steven Rostedt
2011-05-18 18:34 ` [tip:perf/core] " tip-bot for Steven Rostedt
2011-06-16 14:07 ` tip-bot for Steven Rostedt
2011-04-21 2:28 ` [RFC][PATCH 10/11] ftrace/recordmcount: Remove duplicate code to find mcount symbol Steven Rostedt
2011-05-18 18:34 ` [tip:perf/core] " tip-bot for Steven Rostedt
2011-06-16 14:07 ` tip-bot for Steven Rostedt
2011-04-21 2:28 ` [RFC][PATCH 11/11] ftrace/recordmcount: Add helper function get_sym_str_and_relp() Steven Rostedt
2011-05-18 18:35 ` [tip:perf/core] " tip-bot for Steven Rostedt
2011-06-16 14:08 ` tip-bot for Steven Rostedt
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=tip-c6fece27dfa46abc8c4b87d94a8c2f8cd6c5d8b1@git.kernel.org \
--to=srostedt@redhat.com \
--cc=hpa@zytor.com \
--cc=jreiser@bitwagon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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 NNTP newsgroup(s).