]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
misc: simplify if clauses [oclint]
authorSami Kerola <kerolasa@iki.fi>
Mon, 4 Jul 2016 21:09:10 +0000 (22:09 +0100)
committerSami Kerola <kerolasa@iki.fi>
Thu, 21 Jul 2016 20:14:33 +0000 (21:14 +0100)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
26 files changed:
disk-utils/fsck.c
disk-utils/fsck.cramfs.c
disk-utils/fsck.minix.c
disk-utils/mkfs.cramfs.c
disk-utils/mkfs.minix.c
lib/sysfs.c
lib/timeutils.c
libfdisk/src/dos.c
libfdisk/src/sgi.c
libmount/src/fs.c
libmount/src/utils.c
login-utils/sulogin.c
login-utils/utmpdump.c
login-utils/vipw.c
misc-utils/cal.c
misc-utils/mcookie.c
misc-utils/uuidd.c
sys-utils/dmesg.c
sys-utils/ipcrm.c
sys-utils/rtcwake.c
sys-utils/setpriv.c
sys-utils/setsid.c
term-utils/agetty.c
term-utils/setterm.c
text-utils/hexdump-parse.c
text-utils/tailf.c

index eede03810c155c23a5ca802b2a3ca12c0332491b..dd89527032ea49556fc417302a21a2daa272aaa6 100644 (file)
@@ -632,22 +632,21 @@ static int execute(const char *progname, const char *progpath,
        for (i=0; i <num_args; i++)
                argv[argc++] = xstrdup(args[i]);
 
-       if (progress) {
-               if ((strcmp(type, "ext2") == 0) ||
-                   (strcmp(type, "ext3") == 0) ||
-                   (strcmp(type, "ext4") == 0) ||
-                   (strcmp(type, "ext4dev") == 0)) {
-                       char tmp[80];
-
-                       tmp[0] = 0;
-                       if (!progress_active()) {
-                               snprintf(tmp, 80, "-C%d", progress_fd);
-                               inst->flags |= FLAG_PROGRESS;
-                       } else if (progress_fd)
-                               snprintf(tmp, 80, "-C%d", progress_fd * -1);
-                       if (tmp[0])
-                               argv[argc++] = xstrdup(tmp);
-               }
+       if (progress &&
+              ((strcmp(type, "ext2") == 0) ||
+               (strcmp(type, "ext3") == 0) ||
+               (strcmp(type, "ext4") == 0) ||
+               (strcmp(type, "ext4dev") == 0))) {
+
+               char tmp[80];
+               tmp[0] = 0;
+               if (!progress_active()) {
+                       snprintf(tmp, 80, "-C%d", progress_fd);
+                       inst->flags |= FLAG_PROGRESS;
+               } else if (progress_fd)
+                       snprintf(tmp, 80, "-C%d", progress_fd * -1);
+               if (tmp[0])
+                       argv[argc++] = xstrdup(tmp);
        }
 
        argv[argc++] = xstrdup(fs_get_device(fs));
index ef311c103ae4e309b30399c82b383b6954dcb6c1..d904037d388ee18f1d2399fa096b7d35e5bcf960 100644 (file)
@@ -403,10 +403,8 @@ static void do_uncompress(char *path, int outfd, unsigned long offset,
                                     size);
                }
                size -= out;
-               if (*extract_dir != '\0')
-                       if (write(outfd, outbuffer, out) < 0)
-                               err(FSCK_EX_ERROR, _("write failed: %s"),
-                                   path);
+               if (*extract_dir != '\0' && write(outfd, outbuffer, out) < 0)
+                       err(FSCK_EX_ERROR, _("write failed: %s"), path);
                curr = next;
        } while (size);
 }
@@ -629,9 +627,8 @@ static void test_fs(int start)
                             _("directory data end (%lu) != file data start (%lu)"),
                             end_dir, start_data);
        }
-       if (super.flags & CRAMFS_FLAG_FSID_VERSION_2)
-               if (end_data > super.size)
-                       errx(FSCK_EX_UNCORRECTED, _("invalid file data offset"));
+       if (super.flags & CRAMFS_FLAG_FSID_VERSION_2 && end_data > super.size)
+               errx(FSCK_EX_UNCORRECTED, _("invalid file data offset"));
 
        iput(root);             /* free(root) */
 }
index 726f5daaf3dd4b2809025742e55808656bf0d6d7..97e558b76862d26aab9e510a4aab649a79016fe3 100644 (file)
@@ -1333,10 +1333,9 @@ main(int argc, char **argv) {
                usage(stderr);
 
        check_mount();          /* trying to check a mounted filesystem? */
-       if (repair && !automatic) {
-               if (!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO))
-                       die(_("need terminal for interactive repairs"));
-       }
+       if (repair && !automatic && (!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO)))
+               die(_("need terminal for interactive repairs"));
+
        device_fd = open(device_name, repair ? O_RDWR : O_RDONLY);
        if (device_fd < 0)
                die(_("cannot open %s: %s"), device_name, strerror(errno));
index 65ad356b021d4643d06486b09bc711fb8d4e50c5..bb1e4d04c91fdc498ed3baa7e7cd120412ca0d00 100644 (file)
@@ -313,10 +313,9 @@ static unsigned int parse_directory(struct entry *root_entry, const char *name,
                if (dirent->d_name[0] == '.') {
                        if (dirent->d_name[1] == '\0')
                                continue;
-                       if (dirent->d_name[1] == '.') {
-                               if (dirent->d_name[2] == '\0')
-                                       continue;
-                       }
+                       if (dirent->d_name[1] == '.' &&
+                           dirent->d_name[2] == '\0')
+                               continue;
                }
                namelen = strlen(dirent->d_name);
                if (namelen > MAX_INPUT_NAMELEN) {
@@ -352,11 +351,9 @@ static unsigned int parse_directory(struct entry *root_entry, const char *name,
                        entry->size = parse_directory(root_entry, path, &entry->child, fslen_ub);
                } else if (S_ISREG(st.st_mode)) {
                        entry->path = xstrdup(path);
-                       if (entry->size) {
-                               if (entry->size >= (1 << CRAMFS_SIZE_WIDTH)) {
-                                       warn_size = 1;
-                                       entry->size = (1 << CRAMFS_SIZE_WIDTH) - 1;
-                               }
+                       if (entry->size && entry->size >= (1 << CRAMFS_SIZE_WIDTH)) {
+                               warn_size = 1;
+                               entry->size = (1 << CRAMFS_SIZE_WIDTH) - 1;
                        }
                } else if (S_ISLNK(st.st_mode)) {
                        entry->path = xstrdup(path);
index d4a576f838105c9282689b4a6ca240b9fcfe9d45..0e26966e5dfa70160959b3b0eb3d8a61e4425406 100644 (file)
@@ -669,15 +669,11 @@ static int find_super_magic(const struct fs_control *ctl)
        case 1:
                if (ctl->fs_namelen == 14)
                        return MINIX_SUPER_MAGIC;
-               else
-                       return MINIX_SUPER_MAGIC2;
-               break;
+               return MINIX_SUPER_MAGIC2;
        case 2:
                if (ctl->fs_namelen == 14)
                        return MINIX2_SUPER_MAGIC;
-               else
-                       return MINIX2_SUPER_MAGIC2;
-               break;
+               return MINIX2_SUPER_MAGIC2;
        case 3:
                return MINIX3_SUPER_MAGIC;
        default:
index f52b7a885f89755b7df2119203b822b594b57e5f..b52446c20c1ab02454c43f973bccdaefdcc17504 100644 (file)
@@ -785,10 +785,8 @@ int sysfs_devno_to_wholedisk(dev_t dev, char *diskname,
         /*
          * unpartitioned device
          */
-        if (diskname && len) {
-            if (!sysfs_get_devname(&cxt, diskname, len))
-                goto err;
-        }
+        if (diskname && len && !sysfs_get_devname(&cxt, diskname, len))
+            goto err;
         if (diskdevno)
             *diskdevno = dev;
 
index fd9aa3e2e3b2d3465a7bd228c072ccb10e98249d..608e6bdef1e12d0c4531a2708185c467d50d1dfb 100644 (file)
@@ -385,10 +385,8 @@ static int format_iso_time(struct tm *tm, suseconds_t usec, int flags, char *buf
                p += len;
        }
 
-       if (flags & ISO_8601_TIMEZONE) {
-               if (strftime(p, bufsz, "%z", tm) <= 0)
-                       return -1;
-       }
+       if (flags & ISO_8601_TIMEZONE && strftime(p, bufsz, "%z", tm) <= 0)
+               return -1;
 
        return 0;
 }
index b2e1c6038681afedfa04467f28bcba03b6d41a46..5ea56c2ed6a5c0527c1392af018bfbada3bde932 100644 (file)
@@ -1204,20 +1204,18 @@ static int add_partition(struct fdisk_context *cxt, size_t n,
                            (uintmax_t)start,  (uintmax_t)stop, cxt->grain));
        }
 
-       if (stop < limit) {
-               if (isrel && alignment_required(cxt)) {
-                       /* the last sector has not been exactly requested (but
-                        * defined by +size{K,M,G} convention), so be smart and
-                        * align the end of the partition. The next partition
-                        * will start at phy.block boundary.
-                        */
-                       stop = fdisk_align_lba_in_range(cxt, stop, start, limit);
-                       if (stop > start)
-                               stop -= 1;
-                       if (stop > limit)
-                               stop = limit;
-                       DBG(LABEL, ul_debug("DOS: aligned stop: %ju", (uintmax_t) stop));
-               }
+       if (stop < limit && isrel && alignment_required(cxt)) {
+               /* the last sector has not been exactly requested (but
+                * defined by +size{K,M,G} convention), so be smart and
+                * align the end of the partition. The next partition
+                * will start at phy.block boundary.
+                */
+               stop = fdisk_align_lba_in_range(cxt, stop, start, limit);
+               if (stop > start)
+                       stop -= 1;
+               if (stop > limit)
+                       stop = limit;
+               DBG(LABEL, ul_debug("DOS: aligned stop: %ju", (uintmax_t) stop));
        }
 
        set_partition(cxt, n, 0, start, stop, sys, fdisk_partition_is_bootable(pa));
index 73f9049f7e69fffa194ed4740975b97c70160ccd..0ccf2450705137d33349761ffb5d479f9a38dfbe 100644 (file)
@@ -592,9 +592,8 @@ static int verify_disklabel(struct fdisk_context *cxt, int verbose)
                if (sgi_get_num_sectors(cxt, i) != 0) {
                        Index[sortcount++] = i;
                        if (sgi_get_sysid(cxt, i) == SGI_TYPE_ENTIRE_DISK
-                           && entire++ == 1) {
-                               if (verbose)
-                                       fdisk_info(cxt, _("More than one entire "
+                           && entire++ == 1 && verbose) {
+                               fdisk_info(cxt, _("More than one entire "
                                                "disk entry present."));
                        }
                }
index 9cb32934533c37e4f832caf98b6754035c93d7b4..c92b6abcabee1ed5b298308e4387d3dcf21d4c65 100644 (file)
@@ -749,11 +749,10 @@ char *mnt_fs_strdup_options(struct libmnt_fs *fs)
        res = merge_optstr(fs->vfs_optstr, fs->fs_optstr);
        if (!res && errno)
                return NULL;
-       if (fs->user_optstr) {
-               if (mnt_optstr_append_option(&res, fs->user_optstr, NULL)) {
-                       free(res);
-                       res = NULL;
-               }
+       if (fs->user_optstr &&
+           mnt_optstr_append_option(&res, fs->user_optstr, NULL)) {
+               free(res);
+               res = NULL;
        }
        return res;
 }
index 733a0333099277d0630be88e41fc5682bb2d37a5..aa4bc627e1e22e8efd8e4a954025dfff8301d46b 100644 (file)
@@ -454,10 +454,8 @@ static int check_option(const char *haystack, size_t len,
                size_t plen = sep ? (size_t) (sep - p) :
                                    len - (p - haystack);
 
-               if (plen == needle_len) {
-                       if (!strncmp(p, needle, plen))
-                               return !no;     /* foo or nofoo was found */
-               }
+               if (plen == needle_len && !strncmp(p, needle, plen))
+                       return !no;     /* foo or nofoo was found */
                p += plen;
        }
 
index 38ea161c3573f69c09af81accb4964c487f7bbd6..fdbda7c8772a7bf53000e892bbea6f250fc3fbae 100644 (file)
@@ -1105,10 +1105,8 @@ int main(int argc, char **argv)
                }
 
                signum = sigtimedwait(&set, NULL, &sigwait);
-               if (signum != SIGCHLD) {
-                       if (signum < 0 && errno == EAGAIN)
-                               break;
-               }
+               if (signum != SIGCHLD && signum < 0 && errno == EAGAIN)
+                       break;
 
        } while (1);
 
index 1849a4e931c7119a591b2e1461e5d019c7091175..cf8a50d8f28a286783de0a27aa46adab345c2ee8 100644 (file)
@@ -394,9 +394,8 @@ int main(int argc, char **argv)
                in = dump(in, filename, follow, out);
        }
 
-       if (out != stdout)
-               if (close_stream(out))
-                       err(EXIT_FAILURE, _("write failed"));
+       if (out != stdout && close_stream(out))
+               err(EXIT_FAILURE, _("write failed"));
 
        if (in && in != stdin)
                fclose(in);
index 2e343b6ea86da1cf0c6ee50681358030369be30c..d12ea73164606b25d98f9edc06ef41e75aaf1a7c 100644 (file)
@@ -354,10 +354,9 @@ int main(int argc, char *argv[])
                 * which means they can be translated. */
                printf(_("Would you like to edit %s now [y/n]? "), orig_file);
 
-               if (fgets(response, sizeof(response), stdin)) {
-                       if (rpmatch(response) == RPMATCH_YES)
-                               edit_file(1);
-               }
+               if (fgets(response, sizeof(response), stdin) &&
+                   rpmatch(response) == RPMATCH_YES)
+                       edit_file(1);
        }
        exit(EXIT_SUCCESS);
 }
index 2808793824b6a094c21acacd4476f2280049e985..ee8fafb7cb4dcfbb95cd6cc0a8f0d38878972871 100644 (file)
@@ -892,10 +892,8 @@ static int week_number(int day, int month, int32_t year, const struct cal_contro
                month = JANUARY;
 
        yday = day_in_year(day,month,year);
-       if (year == REFORMATION_YEAR) {
-               if (yday >= YDAY_AFTER_MISSING)
-                       fday -= NUMBER_MISSING_DAYS;
-       }
+       if (year == REFORMATION_YEAR && yday >= YDAY_AFTER_MISSING)
+               fday -= NUMBER_MISSING_DAYS;
 
        /* Last year is last year */
        if (yday + fday < DAYS_IN_WEEK)
index f26d4d2578bccc9a33b3c33006ee58bac5d8fac3..ffeb36abee367b7cf51bc295fafa9698bd9300da 100644 (file)
@@ -121,10 +121,8 @@ static void randomness_from_files(struct mcookie_control *ctl)
                                           "Got %zu bytes from %s\n", count),
                                        count, fname);
 
-                       if (fd != STDIN_FILENO)
-                               if (close(fd))
-                                       err(EXIT_FAILURE,
-                                           _("closing %s failed"), fname);
+                       if (fd != STDIN_FILENO && close(fd))
+                               err(EXIT_FAILURE, _("closing %s failed"), fname);
                }
        }
 }
index 4b1782ae18b67a997e029d20ed0ec54246121809..a3fe83044246db54e297fe0c5af44e5b67c3b609 100644 (file)
@@ -371,9 +371,8 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
                        if (ftruncate(fd_pidfile, 0))
                                err(EXIT_FAILURE, _("could not truncate file: %s"), pidfile_path);
                        write_all(fd_pidfile, reply_buf, strlen(reply_buf));
-                       if (fd_pidfile > 1)
-                               if (close_fd(fd_pidfile) != 0) /* Unlock the pid file */
-                                       err(EXIT_FAILURE, _("write failed: %s"), pidfile_path);
+                       if (fd_pidfile > 1 && close_fd(fd_pidfile) != 0)
+                               err(EXIT_FAILURE, _("write failed: %s"), pidfile_path);
                }
 
        }
index 36c966f6a6457c937619b8eff889516e767dd819..45443884279b0abbe02131c8aeb8a48fc17b4e14 100644 (file)
@@ -1116,8 +1116,6 @@ static int parse_kmsg_record(struct dmesg_control *ctl,
 
        /* D) optional fields (ignore) */
        p = skip_item(p, end, ";");
-       if (LAST_KMSG_FIELD(p))
-               goto mesg;
 
 mesg:
        /* E) message text */
@@ -1391,12 +1389,11 @@ int main(int argc, char *argv[])
        if (argc > 1)
                usage(stderr);
 
-       if (is_timefmt(&ctl, RELTIME) ||
-           is_timefmt(&ctl, CTIME) ||
-           is_timefmt(&ctl, ISO8601)) {
-               if (dmesg_get_boot_time(&ctl.boot_time) != 0)
-                       ctl.time_fmt = DMESG_TIMEFTM_NONE;
-       }
+       if ((is_timefmt(&ctl, RELTIME) ||
+            is_timefmt(&ctl, CTIME)   ||
+            is_timefmt(&ctl, ISO8601))
+           && dmesg_get_boot_time(&ctl.boot_time) != 0)
+               ctl.time_fmt = DMESG_TIMEFTM_NONE;
 
        if (delta)
                switch (ctl.time_fmt) {
index 0b40f1539b3fb928d7edd0db68cfc330ea218248..7912feed9f5efb3ad21057b2280ce2179d1cd014 100644 (file)
@@ -407,9 +407,8 @@ int main(int argc, char **argv)
                }
        }
 
-       if (rm_all)
-               if (remove_all(what_all))
-                       ret++;
+       if (rm_all && remove_all(what_all))
+               ret++;
 
        /* print usage if we still have some arguments left over */
        if (optind < argc) {
index 72894eab8d0d85049b86a41e794e64ce4de006ca..053baf5efaea975ec272d46fba8f50089d7b9456 100644 (file)
@@ -501,12 +501,9 @@ int main(int argc, char **argv)
                }
        }
 
-       if (ctl.clock_mode == CM_AUTO) {
-               if (read_clock_mode(&ctl) < 0) {
-                       printf(_("%s: assuming RTC uses UTC ...\n"),
-                                       program_invocation_short_name);
-                       ctl.clock_mode = CM_UTC;
-               }
+       if (ctl.clock_mode == CM_AUTO && read_clock_mode(&ctl) < 0) {
+               printf(_("%s: assuming RTC uses UTC ...\n"),  program_invocation_short_name);
+               ctl.clock_mode = CM_UTC;
        }
 
        if (ctl.verbose)
index 1630122230e8ddc2a5bc91669ddea0cb7261feff..3b99a177e03be3f5ffe7484e7c52769a08ea861e 100644 (file)
@@ -781,9 +781,8 @@ int main(int argc, char **argv)
                errx(EXIT_FAILURE,
                     _("--[re]gid requires --keep-groups, --clear-groups, or --groups"));
 
-       if (opts.nnp)
-               if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) == -1)
-                       err(EXIT_FAILURE, _("disallow granting new privileges failed"));
+       if (opts.nnp && prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) == -1)
+               err(EXIT_FAILURE, _("disallow granting new privileges failed"));
 
        if (opts.selinux_label)
                do_selinux_label(opts.selinux_label);
@@ -820,9 +819,8 @@ int main(int argc, char **argv)
                        err(SETPRIV_EXIT_PRIVERR, _("setgroups failed"));
        }
 
-       if (opts.have_securebits)
-               if (prctl(PR_SET_SECUREBITS, opts.securebits, 0, 0, 0) != 0)
-                       err(SETPRIV_EXIT_PRIVERR, _("set process securebits failed"));
+       if (opts.have_securebits && prctl(PR_SET_SECUREBITS, opts.securebits, 0, 0, 0) != 0)
+               err(SETPRIV_EXIT_PRIVERR, _("set process securebits failed"));
 
        if (opts.bounding_set) {
                do_caps(CAPNG_BOUNDING_SET, opts.bounding_set);
index bb089df21ec8cbdc0a03083b93c5b239846c8302..bae97ff9bd3390f02e51804aee752c8cd4b95a8d 100644 (file)
@@ -109,10 +109,8 @@ int main(int argc, char **argv)
                /* cannot happen */
                err(EXIT_FAILURE, _("setsid failed"));
 
-       if (ctty) {
-               if (ioctl(STDIN_FILENO, TIOCSCTTY, 1))
-                       err(EXIT_FAILURE, _("failed to set the controlling terminal"));
-       }
+       if (ctty && ioctl(STDIN_FILENO, TIOCSCTTY, 1))
+               err(EXIT_FAILURE, _("failed to set the controlling terminal"));
        execvp(argv[optind], argv + optind);
        err(EXIT_FAILURE, _("failed to execute %s"), argv[optind]);
 }
index b73884828bca737770ab94a9db1c8410d0297c19..07d82b9fb5d0b1a2ece99b89526f643e4cc62ca2 100644 (file)
@@ -502,21 +502,16 @@ int main(int argc, char **argv)
 
        login_argv[login_argc] = NULL;  /* last login argv */
 
-       if (options.chroot) {
-               if (chroot(options.chroot) < 0)
-                       log_err(_("%s: can't change root directory %s: %m"),
-                               options.tty, options.chroot);
-       }
-       if (options.chdir) {
-               if (chdir(options.chdir) < 0)
-                       log_err(_("%s: can't change working directory %s: %m"),
-                               options.tty, options.chdir);
-       }
-       if (options.nice) {
-               if (nice(options.nice) < 0)
-                       log_warn(_("%s: can't change process priority: %m"),
-                               options.tty);
-       }
+       if (options.chroot && chroot(options.chroot) < 0)
+               log_err(_("%s: can't change root directory %s: %m"),
+                       options.tty, options.chroot);
+       if (options.chdir && chdir(options.chdir) < 0)
+               log_err(_("%s: can't change working directory %s: %m"),
+                       options.tty, options.chdir);
+       if (options.nice && nice(options.nice) < 0)
+               log_warn(_("%s: can't change process priority: %m"),
+                        options.tty);
+
        free(options.osrelease);
 #ifdef DEBUGGING
        if (close_stream(dbf) != 0)
index 13836e99abf0efd0fa08e5e2c3ad9fdd6c412669..704fc59dc8f530666816440a9344a424d321837a 100644 (file)
@@ -809,11 +809,9 @@ static void screendump(struct setterm_control *ctl)
 /* Some options are applicable when terminal is virtual console. */
 static int vc_only(struct setterm_control *ctl, const char *err)
 {
-       if (!ctl->vcterm) {
-               if (err)
-                       warnx(_("terminal %s does not support %s"),
-                             ctl->opt_te_terminal_name, err);
-       }
+       if (!ctl->vcterm && err)
+               warnx(_("terminal %s does not support %s"),
+                     ctl->opt_te_terminal_name, err);
        return ctl->vcterm;
 }
 
index 9eb016d6a1e0a97535186835e1924a0cf5e14cd7..c60a4d06b66dbf3b376a003583d9e4893d0cf3e4 100644 (file)
@@ -460,15 +460,12 @@ isint:                            cs[3] = '\0';
                        fs->bcnt < hex->blocksize &&
                        !(fu->flags&F_SETREP) && fu->bcnt)
                                fu->reps += (hex->blocksize - fs->bcnt) / fu->bcnt;
-               if (fu->reps > 1) {
-                       if (!list_empty(&fu->prlist)) {
-                               pr = list_last_entry(&fu->prlist,
-                                 struct hexdump_pr, prlist);
-                               for (p1 = pr->fmt, p2 = NULL; *p1; ++p1)
-                                       p2 = isspace(*p1) ? p1 : NULL;
-                               if (p2)
-                                       pr->nospace = p2;
-                       }
+               if (fu->reps > 1 && !list_empty(&fu->prlist)) {
+                       pr = list_last_entry(&fu->prlist, struct hexdump_pr, prlist);
+                       for (p1 = pr->fmt, p2 = NULL; *p1; ++p1)
+                               p2 = isspace(*p1) ? p1 : NULL;
+                       if (p2)
+                               pr->nospace = p2;
                }
        }
 }
index 34d0cd53b18f4f233c63d450c3b48d8341b5da60..c111d02c0ebd0f72efe7a9a230dcc78fb686f17e 100644 (file)
@@ -74,11 +74,9 @@ static void tailf(const char *filename, size_t lines, struct stat *st)
        if (data[i] == '\n')
                lines++;
        while (i) {
-               if (data[i] == '\n') {
-                       if (--lines == 0) {
-                               i++;
-                               break;
-                       }
+               if (data[i] == '\n' && --lines == 0) {
+                       i++;
+                       break;
                }
                i--;
        }