@@ -78,7 +78,7 @@ static off_t
7878ulseek (int const fd , off_t const offset , int const whence )
7979{
8080 off_t const w = lseek (fd , offset , whence );
81- if ((off_t )- 1 == w ) {
81+ if (w == (off_t )- 1 ) {
8282 perror ("lseek" );
8383 fail_file ();
8484 }
@@ -111,7 +111,7 @@ static void *
111111umalloc (size_t size )
112112{
113113 void * const addr = malloc (size );
114- if (0 == addr ) {
114+ if (addr == 0 ) {
115115 fprintf (stderr , "malloc failed: %zu bytes\n" , size );
116116 fail_file ();
117117 }
@@ -136,7 +136,7 @@ static void *mmap_file(char const *fname)
136136 void * addr ;
137137
138138 fd_map = open (fname , O_RDWR );
139- if (0 > fd_map || 0 > fstat (fd_map , & sb )) {
139+ if (fd_map < 0 || fstat (fd_map , & sb ) < 0 ) {
140140 perror (fname );
141141 fail_file ();
142142 }
@@ -147,7 +147,7 @@ static void *mmap_file(char const *fname)
147147 addr = mmap (0 , sb .st_size , PROT_READ |PROT_WRITE , MAP_PRIVATE ,
148148 fd_map , 0 );
149149 mmap_failed = 0 ;
150- if (MAP_FAILED == addr ) {
150+ if (addr == MAP_FAILED ) {
151151 mmap_failed = 1 ;
152152 addr = umalloc (sb .st_size );
153153 uread (fd_map , addr , sb .st_size );
@@ -206,12 +206,12 @@ static uint32_t (*w2)(uint16_t);
206206static int
207207is_mcounted_section_name (char const * const txtname )
208208{
209- return 0 == strcmp (".text" , txtname ) ||
210- 0 == strcmp (".ref.text" , txtname ) ||
211- 0 == strcmp (".sched.text" , txtname ) ||
212- 0 == strcmp (".spinlock.text" , txtname ) ||
213- 0 == strcmp (".irqentry.text" , txtname ) ||
214- 0 == strcmp (".text.unlikely" , txtname );
209+ return strcmp (".text" , txtname ) == 0 ||
210+ strcmp (".ref.text" , txtname ) == 0 ||
211+ strcmp (".sched.text" , txtname ) == 0 ||
212+ strcmp (".spinlock.text" , txtname ) == 0 ||
213+ strcmp (".irqentry.text" , txtname ) == 0 ||
214+ strcmp (".text.unlikely" , txtname ) == 0 ;
215215}
216216
217217/* 32 bit and 64 bit are very similar */
@@ -270,25 +270,25 @@ do_file(char const *const fname)
270270 fail_file ();
271271 } break ;
272272 case ELFDATA2LSB : {
273- if (1 != * (unsigned char const * )& endian ) {
273+ if (* (unsigned char const * )& endian != 1 ) {
274274 /* main() is big endian, file.o is little endian. */
275275 w = w4rev ;
276276 w2 = w2rev ;
277277 w8 = w8rev ;
278278 }
279279 } break ;
280280 case ELFDATA2MSB : {
281- if (0 != * (unsigned char const * )& endian ) {
281+ if (* (unsigned char const * )& endian != 0 ) {
282282 /* main() is little endian, file.o is big endian. */
283283 w = w4rev ;
284284 w2 = w2rev ;
285285 w8 = w8rev ;
286286 }
287287 } break ;
288288 } /* end switch */
289- if (0 != memcmp (ELFMAG , ehdr -> e_ident , SELFMAG )
290- || ET_REL != w2 (ehdr -> e_type )
291- || EV_CURRENT != ehdr -> e_ident [EI_VERSION ]) {
289+ if (memcmp (ELFMAG , ehdr -> e_ident , SELFMAG ) != 0
290+ || w2 (ehdr -> e_type ) != ET_REL
291+ || ehdr -> e_ident [EI_VERSION ] != EV_CURRENT ) {
292292 fprintf (stderr , "unrecognized ET_REL file %s\n" , fname );
293293 fail_file ();
294294 }
@@ -321,31 +321,31 @@ do_file(char const *const fname)
321321 fail_file ();
322322 } break ;
323323 case ELFCLASS32 : {
324- if (sizeof ( Elf32_Ehdr ) != w2 ( ehdr -> e_ehsize )
325- || sizeof ( Elf32_Shdr ) != w2 ( ehdr -> e_shentsize )) {
324+ if (w2 ( ehdr -> e_ehsize ) != sizeof ( Elf32_Ehdr )
325+ || w2 ( ehdr -> e_shentsize ) != sizeof ( Elf32_Shdr )) {
326326 fprintf (stderr ,
327327 "unrecognized ET_REL file: %s\n" , fname );
328328 fail_file ();
329329 }
330- if (EM_S390 == w2 (ehdr -> e_machine ))
330+ if (w2 (ehdr -> e_machine ) == EM_S390 )
331331 reltype = R_390_32 ;
332- if (EM_MIPS == w2 (ehdr -> e_machine )) {
332+ if (w2 (ehdr -> e_machine ) == EM_MIPS ) {
333333 reltype = R_MIPS_32 ;
334334 is_fake_mcount32 = MIPS32_is_fake_mcount ;
335335 }
336336 do32 (ehdr , fname , reltype );
337337 } break ;
338338 case ELFCLASS64 : {
339339 Elf64_Ehdr * const ghdr = (Elf64_Ehdr * )ehdr ;
340- if (sizeof ( Elf64_Ehdr ) != w2 ( ghdr -> e_ehsize )
341- || sizeof ( Elf64_Shdr ) != w2 ( ghdr -> e_shentsize )) {
340+ if (w2 ( ghdr -> e_ehsize ) != sizeof ( Elf64_Ehdr )
341+ || w2 ( ghdr -> e_shentsize ) != sizeof ( Elf64_Shdr )) {
342342 fprintf (stderr ,
343343 "unrecognized ET_REL file: %s\n" , fname );
344344 fail_file ();
345345 }
346- if (EM_S390 == w2 (ghdr -> e_machine ))
346+ if (w2 (ghdr -> e_machine ) == EM_S390 )
347347 reltype = R_390_64 ;
348- if (EM_MIPS == w2 (ghdr -> e_machine )) {
348+ if (w2 (ghdr -> e_machine ) == EM_MIPS ) {
349349 reltype = R_MIPS_64 ;
350350 Elf64_r_sym = MIPS64_r_sym ;
351351 Elf64_r_info = MIPS64_r_info ;
@@ -371,7 +371,7 @@ main(int argc, char const *argv[])
371371 }
372372
373373 /* Process each file in turn, allowing deep failure. */
374- for (-- argc , ++ argv ; 0 < argc ; -- argc , ++ argv ) {
374+ for (-- argc , ++ argv ; argc > 0 ; -- argc , ++ argv ) {
375375 int const sjval = setjmp (jmpenv );
376376 int len ;
377377
0 commit comments