File rmlint-2.2.0-git.patch of Package rmlint

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4fab905..ca168eb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,16 +6,6 @@ The format follows [keepachangelog.com]. Please stick to it.
 
 ## [2.3.0 (No name yet)] -- [unreleased]
 
-### Roadmap
-
-- Feature: Find biggest lint suckers.
-- --read: Just re-output json to different format.
-- traverse: get rid of fts(). (*sigh*)
-- gui: provide a basic working version.
-- tests: provide speed regression test (need a platform for that in background first)
-- feature: add back reflink support.
-- sh/py formatter: add safety net checks before removing.
-
 ## [2.2.0 Dreary Dropbear] -- 2015-05-09
 
 ### Fixed
diff --git a/SConstruct b/SConstruct
index dec54a0..cc434c0 100755
--- a/SConstruct
+++ b/SConstruct
@@ -8,6 +8,7 @@ import subprocess
 
 import SCons.Conftest as tests
 
+pkg_config = os.getenv('PKG_CONFIG') or 'pkg-config'
 
 def read_version():
     with open('.version', 'r') as handle:
@@ -32,7 +33,7 @@ Export('VERSION_MAJOR VERSION_MINOR VERSION_PATCH VERSION_NAME')
 
 def check_pkgconfig(context, version):
     context.Message('Checking for pkg-config... ')
-    command = 'pkg-config --atleast-pkgconfig-version=%s' % version
+    command = pkg_config + ' --atleast-pkgconfig-version=' + version
     ret = context.TryAction(command)[0]
     context.Result(ret)
     return ret
@@ -50,7 +51,7 @@ def check_pkg(context, name, varname, required=True):
 
     if rc is not 0:
         context.Message('Checking for %s... ' % name)
-        rc, text = context.TryAction('pkg-config --exists \'%s\'' % name)
+        rc, text = context.TryAction('%s --exists \'%s\'' % (pkg_config, name))
 
     # 0 is defined as error by TryAction
     if rc is 0 and required:
@@ -287,6 +288,17 @@ def check_sqlite3(context):
     return rc
 
 
+def check_linux_limits(context):
+    rc = 1
+    if tests.CheckHeader(context, 'linux/limits.h'):
+        rc = 0
+
+    conf.env['HAVE_LINUX_LIMITS'] = rc
+    context.did_show_result = True
+    context.Result(rc)
+    return rc
+
+
 def create_uninstall_target(env, path):
     env.Command("uninstall-" + path, path, [
         Delete("$SOURCE"),
@@ -448,7 +460,8 @@ conf = Configure(env, custom_tests={
     'check_bigfiles': check_bigfiles,
     'check_c11': check_c11,
     'check_gettext': check_gettext,
-    'check_sqlite3': check_sqlite3
+    'check_sqlite3': check_sqlite3,
+    'check_linux_limits': check_linux_limits
 })
 
 if not conf.CheckCC():
@@ -537,7 +550,7 @@ conf.env.Append(CFLAGS=[
     '-Wstrict-prototypes',
 ])
 
-env.ParseConfig('pkg-config --cflags --libs ' + ' '.join(packages))
+env.ParseConfig(pkg_config + ' --cflags --libs ' + ' '.join(packages))
 
 
 conf.env.Append(_LIBFLAGS=['-lm'])
@@ -552,6 +565,7 @@ conf.check_bigfiles()
 conf.check_sha512()
 conf.check_gettext()
 conf.check_sqlite3()
+conf.check_linux_limits()
 
 if conf.env['HAVE_LIBELF']:
     conf.env.Append(_LIBFLAGS=['-lelf'])
diff --git a/docs/SConscript b/docs/SConscript
index a3e0054..38e754d 100644
--- a/docs/SConscript
+++ b/docs/SConscript
@@ -63,6 +63,7 @@ env.Alias('man', env.Depends(manpage, sphinx))
 
 
 if 'install' in COMMAND_LINE_TARGETS:
+    manpage[0].build()
     if os.access(str(manpage[0]), os.R_OK):
         man_install = env.Install('$PREFIX/share/man/man1', [manpage])
         env.Alias('install', [man_install])
diff --git a/lib/SConscript b/lib/SConscript
index 91c220a..65264d6 100644
--- a/lib/SConscript
+++ b/lib/SConscript
@@ -33,6 +33,7 @@ def build_config_template(target, source, env):
             HAVE_SYSBLOCK=env['HAVE_SYSBLOCK'],
             HAVE_SYSCTL=env['HAVE_SYSCTL'],
             HAVE_SQLITE3=env['HAVE_SQLITE3'],
+            HAVE_LINUX_LIMITS=env['HAVE_LINUX_LIMITS'],
             VERSION_MAJOR=VERSION_MAJOR,
             VERSION_MINOR=VERSION_MINOR,
             VERSION_PATCH=VERSION_PATCH,
diff --git a/lib/cmdline.c b/lib/cmdline.c
index a4c726a..9d16fcf 100644
--- a/lib/cmdline.c
+++ b/lib/cmdline.c
@@ -1217,7 +1217,7 @@ bool rm_cmd_parse_args(int argc, char **argv, RmSession *session) {
     if(cfg->with_color) {
         cfg->with_stdout_color = isatty(fileno(stdout));
         cfg->with_stderr_color = isatty(fileno(stdout));
-        cfg->with_color = (cfg->with_stderr_color | cfg->with_stderr_color);
+        cfg->with_color = (cfg->with_stdout_color | cfg->with_stderr_color);
     } else {
         cfg->with_stdout_color = cfg->with_stderr_color = 0;
     }
diff --git a/lib/config.h.in b/lib/config.h.in
index 5201aa7..65401c3 100644
--- a/lib/config.h.in
+++ b/lib/config.h.in
@@ -18,6 +18,7 @@
 #define HAVE_SYSBLOCK      ({HAVE_SYSBLOCK})
 #define HAVE_SYSCTL        ({HAVE_SYSCTL})
 #define HAVE_SQLITE3       ({HAVE_SQLITE3})
+#define HAVE_LINUX_LIMITS  ({HAVE_LINUX_LIMITS})
 
 #define RM_DEFAULT_DIGEST RM_DIGEST_SHA1
 #define RM_VERSION "{VERSION_MAJOR}.{VERSION_MINOR}.{VERSION_PATCH}"
@@ -45,6 +46,14 @@
 
 #include <errno.h>
 
+#if HAVE_LINUX_LIMITS
+#include <linux/limits.h>
+#else
+# ifndef PATH_MAX
+#  define PATH_MAX 4096
+# endif
+#endif
+
 #define rm_log_debug(...) \
     g_log("rmlint", G_LOG_LEVEL_DEBUG, __VA_ARGS__)
 #define rm_log_info(...) \
diff --git a/lib/pathtricia.c b/lib/pathtricia.c
index 78cbfbc..c98b327 100644
--- a/lib/pathtricia.c
+++ b/lib/pathtricia.c
@@ -27,7 +27,6 @@
 #include <stdbool.h>
 #include <string.h>
 #include <glib.h>
-#include <linux/limits.h>
 
 #include "pathtricia.h"
 #include "config.h"
diff --git a/lib/session.h b/lib/session.h
index 63c21ba..8062137 100644
--- a/lib/session.h
+++ b/lib/session.h
@@ -49,7 +49,6 @@ typedef struct RmFileTables {
 } RmFileTables;
 
 struct RmFmtTable;
-struct RmTreeMerger;
 
 typedef struct RmSession {
     RmCfg *cfg;
diff --git a/lib/shredder.c b/lib/shredder.c
index 1dbcf87..23830de 100644
--- a/lib/shredder.c
+++ b/lib/shredder.c
@@ -1089,7 +1089,7 @@ static gboolean rm_shred_group_push_file(RmShredGroup *shred_group, RmFile *file
     g_mutex_lock(&shred_group->lock);
     {
         shred_group->has_pref |= file->is_prefd | file->hardlinks.has_prefd;
-        shred_group->has_npref |= !file->is_prefd | file->hardlinks.has_non_prefd;
+        shred_group->has_npref |= (!file->is_prefd) | file->hardlinks.has_non_prefd;
         shred_group->has_new |= file->is_new_or_has_new;
 
         shred_group->ref_count++;
@@ -1154,7 +1154,6 @@ static gboolean rm_shred_sift(RmFile *file) {
     g_assert(file);
     g_assert(file->shred_group);
 
-    RmShredGroup *child_group = NULL;
     RmShredGroup *current_group = file->shred_group;
 
     if(file->status == RM_FILE_STATE_IGNORE) {
@@ -1163,6 +1162,8 @@ static gboolean rm_shred_sift(RmFile *file) {
     } else {
         g_assert(file->digest);
 
+        RmShredGroup *child_group = NULL;
+
         if(file->digest->type == RM_DIGEST_PARANOID && !file->is_symlink) {
             g_assert(file->digest->bytes ==
                      current_group->next_offset - current_group->hash_offset);
diff --git a/lib/swap-table.c b/lib/swap-table.c
index 0c9e8a7..d35cbf7 100644
--- a/lib/swap-table.c
+++ b/lib/swap-table.c
@@ -3,8 +3,7 @@
 #include <unistd.h>
 #include <errno.h>
 
-#include <linux/limits.h>
-
+#include "config.h"
 #include "swap-table.h"
 
 #if HAVE_SQLITE3
@@ -84,8 +83,7 @@ static void rm_swap_table_clean_stmt(RmSwapTable *self, sqlite3_stmt *stmt,
     g_assert(self);
     g_assert(stmt);
 
-    int r = 0;
-    if((r = sqlite3_errcode(self->cache)) != SQLITE_DONE) {
+    if(sqlite3_errcode(self->cache) != SQLITE_DONE) {
         SET_ERROR("stmt failed: %s", sqlite3_errmsg(self->cache));
     }
 
diff --git a/lib/traverse.c b/lib/traverse.c
index 0a11850..2748451 100644
--- a/lib/traverse.c
+++ b/lib/traverse.c
@@ -26,9 +26,10 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <fts.h>
 #include <errno.h>
-#include <sys/stat.h>
 
 #include <glib.h>
 
diff --git a/lib/treemerge.c b/lib/treemerge.c
index f2ebaf7..87e3b36 100644
--- a/lib/treemerge.c
+++ b/lib/treemerge.c
@@ -57,6 +57,9 @@
 
 #include <glib.h>
 #include <string.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <fts.h>
 
 #include "treemerge.h"
@@ -66,22 +69,21 @@
 #include "pathtricia.h"
 
 typedef struct RmDirectory {
-    char *dirname;        /* Path to this directory without trailing slash              */
-    GQueue known_files;   /* RmFiles in this directory                                  */
-    GQueue children;      /* Children for directories with subdirectories               */
-    gint64 prefd_files;   /* Files in this directory that are tagged as original        */
-    gint64 dupe_count;    /* Count of RmFiles actually in this directory                */
-    gint64 file_count;    /* Count of files actually in this directory (or -1 on error) */
-    gint64 mergeups;      /* number of times this directory was merged up               */
-    bool finished;        /* Was this dir or one of his parents already printed?        */
-    bool was_merged;      /* true if this directory was merged up already (only once)   */
-    bool was_inserted;    /* true if this directory was added to results (only once)    */
-    unsigned short depth; /* path depth (i.e. count of / in path, no trailing /)        */
-    GHashTable *hash_set; /* Set of hashes, used for equality check (to be sure)        */
-    RmDigest *digest;     /* Common digest of all RmFiles in this directory             */
+    char *dirname;         /* Path to this directory without trailing slash              */
+    GQueue known_files;    /* RmFiles in this directory                                  */
+    GQueue children;       /* Children for directories with subdirectories               */
+    gint64 prefd_files;    /* Files in this directory that are tagged as original        */
+    gint64 dupe_count;     /* Count of RmFiles actually in this directory                */
+    gint64 file_count;     /* Count of files actually in this directory (or -1 on error) */
+    gint64 mergeups;       /* number of times this directory was merged up               */
+    bool finished : 1;     /* Was this dir or one of his parents already printed?        */
+    bool was_merged : 1;   /* true if this directory was merged up already (only once)   */
+    bool was_inserted : 1; /* true if this directory was added to results (only once)    */
+    unsigned short depth;  /* path depth (i.e. count of / in path, no trailing /)        */
+    GHashTable *hash_set;  /* Set of hashes, used for equality check (to be sure)        */
+    RmDigest *digest;      /* Common digest of all RmFiles in this directory             */
 
     struct {
-        bool has_metadata; /* stat(2) called already                */
         time_t dir_mtime;  /* Directory Metadata: Modification Time */
         ino_t dir_inode;   /* Directory Metadata: Inode             */
         dev_t dir_dev;     /* Directory Metadata: Device ID         */
@@ -857,7 +859,6 @@ static void rm_tm_extract(RmTreeMerger *self) {
 
     GQueue *file_list = NULL;
     while(g_hash_table_iter_next(&iter, NULL, (void **)&file_list)) {
-        bool has_one_dupe = false;
         RmOff file_size_acc = 0;
 
         GList *next = NULL;
@@ -865,15 +866,14 @@ static void rm_tm_extract(RmTreeMerger *self) {
             RmFile *file = iter->data;
             next = iter->next;
 
-            bool is_duplicate = g_hash_table_contains(self->file_checks, file->digest);
-            has_one_dupe |= is_duplicate;
-
             /* with --partial-hidden we do not want to output */
             if(self->session->cfg->partial_hidden && file->is_hidden) {
                 g_queue_delete_link(file_list, iter);
                 continue;
             }
 
+            bool is_duplicate = g_hash_table_contains(self->file_checks, file->digest);
+
             if(iter != file_list->head && !is_duplicate) {
                 file_size_acc += file->file_size;
             }
diff --git a/lib/utilities.c b/lib/utilities.c
index 0ddf0a7..536ffe3 100644
--- a/lib/utilities.c
+++ b/lib/utilities.c
@@ -969,8 +969,7 @@ dev_t rm_mounts_get_disk_id(RmMountTable *self, dev_t partition, const char *pat
          * to *
          * a recognisable partition */
         char *prev = g_strdup(path);
-        while
-            TRUE {
+        while(TRUE) {
                 char *temp = g_strdup(prev);
                 char *parent_path = g_strdup(dirname(temp));
                 g_free(temp);
@@ -1227,7 +1226,7 @@ RmOff rm_offset_lookup(_U RmOffsetTable table, _U RmOff file_offset) {
     return 0;
 }
 
-bool rm_offsets_match(RmOffsetTable table1, RmOffsetTable table2) {
+bool rm_offsets_match(_U RmOffsetTable table1, _U RmOffsetTable table2) {
     return false;
 }
 
diff --git a/tests/test_options/test_sorting.py b/tests/test_options/test_sorting.py
index d36a99d..1e07fa8 100644
--- a/tests/test_options/test_sorting.py
+++ b/tests/test_options/test_sorting.py
@@ -76,4 +76,3 @@ def test_sorting():
         assert len(data) == 6
 
         validate_order(data, combo)
-        print('ok')
openSUSE Build Service is sponsored by