summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorKacper <kacper@mail.openlinux.dev>2025-12-09 23:14:53 +0100
committerKacper <kacper@mail.openlinux.dev>2025-12-09 23:14:53 +0100
commit169daa11155988a210fac949297381743f3cb400 (patch)
tree602ef5df5ae9ea075ab3d5dac3c8ad60da1ea2cc /bin
parent4e2112e165fdd94dee58378e3ea32892f3710cd7 (diff)
feat: clang-tidy fixes
Diffstat (limited to 'bin')
-rw-r--r--bin/echo/echo.c6
-rw-r--r--bin/gzip/deflate.c12
-rw-r--r--bin/gzip/gzip.c38
-rw-r--r--bin/gzip/gzip.h6
-rw-r--r--bin/gzip/inflate.c11
-rw-r--r--bin/gzip/trees.c20
-rw-r--r--bin/gzip/unzip.c4
-rw-r--r--bin/gzip/util.c20
-rw-r--r--bin/gzip/zip.c3
9 files changed, 60 insertions, 60 deletions
diff --git a/bin/echo/echo.c b/bin/echo/echo.c
index b8e5bbe0..b5ceee1c 100644
--- a/bin/echo/echo.c
+++ b/bin/echo/echo.c
@@ -1,6 +1,6 @@
-#include <string.h>
-#include <unistd.h>
-#include <sys/uio.h>
+#include <string.h> // for strlen
+#include <sys/uio.h> // for iovec, writev
+#include <unistd.h> // for STDOUT_FILENO
int main(int argc, char **argv)
{
diff --git a/bin/gzip/deflate.c b/bin/gzip/deflate.c
index 61e4d92b..2f839851 100644
--- a/bin/gzip/deflate.c
+++ b/bin/gzip/deflate.c
@@ -61,10 +61,12 @@
* attributes.
*/
+#include "stddef.h"
#include <stdio.h>
-#include "tailor.h"
#include "gzip.h"
+#include "tailor.h"
+#include <string.h>
#ifdef RCSID
static char rcsid[] = "$Id: deflate.c,v 1.1 2002/08/18 00:59:21 hpa Exp $";
@@ -266,7 +268,7 @@ local void check_match OF((IPos start, IPos match, int length));
* input characters, so that a running hash key can be computed from the
* previous key instead of complete recalculation each time.
*/
-#define UPDATE_HASH(h, c) (h = (((h) << H_SHIFT) ^ (c)) & HASH_MASK)
+#define UPDATE_HASH(h, c) ((h) = (((h) << H_SHIFT) ^ (c)) & HASH_MASK)
/* ===========================================================================
* Insert string s in the dictionary and set match_head to the previous head
@@ -278,14 +280,12 @@ local void check_match OF((IPos start, IPos match, int length));
*/
#define INSERT_STRING(s, match_head) \
(UPDATE_HASH(ins_h, window[(s) + MIN_MATCH - 1]), \
- prev[(s) & WMASK] = match_head = head[ins_h], head[ins_h] = (s))
+ prev[(s) & WMASK] = (match_head) = head[ins_h], head[ins_h] = (s))
/* ===========================================================================
* Initialize the "longest match" routines for a new file
*/
-void lm_init(pack_level, flags) int pack_level; /* 0: store, 1: best speed, 9:
- best compression */
-ush *flags; /* general purpose bit flag */
+void lm_init(int pack_level, ush *flags)
{
register unsigned j;
diff --git a/bin/gzip/gzip.c b/bin/gzip/gzip.c
index bc7a4bf2..b0e20bb1 100644
--- a/bin/gzip/gzip.c
+++ b/bin/gzip/gzip.c
@@ -9,6 +9,11 @@
* See the file algorithm.doc for the compression algorithms and file formats.
*/
+#include "stddef.h" // for NULL
+
+#include <stdio.h> // for fprintf, stderr, perror, fileno, stdin, stdout
+#include <string.h> // for strcpy, strcmp, strlen, strcat, memcmp, strncmp
+
static char *license_msg[] = {
" Copyright (C) 1992-1993 Jean-loup Gailly",
" This program is free software; you can redistribute it and/or modify",
@@ -49,21 +54,18 @@ static char *license_msg[] = {
static char rcsid[] = "$Id: gzip.c,v 1.3 2005/02/12 21:03:28 olh Exp $";
#endif
-#include <sys/types.h>
-#include <signal.h>
-#include <sys/stat.h>
-#include <errno.h>
-
-#include "tailor.h"
#include "gzip.h"
-#include "revision.h"
-
-#include <time.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include <utime.h>
+#include "revision.h" // for REVDATE, VERSION
+#include "tailor.h" // for MAX_SUFFIX, PATH_SEP, get_char, MIN_PART, OPTI...
+
+#include <errno.h> // for errno, ENAMETOOLONG, ENOENT
+#include <fcntl.h> // for open, O_RDONLY, O_CREAT, O_EXCL, O_WRONLY
+#include <signal.h> // for sysv_signal, SIG_IGN, SIGHUP, SIGTERM, SIGINT
+#include <stdlib.h> // for exit, free
+#include <sys/stat.h> // for stat, chmod, st_mtime, fstat, S_IRUSR, S_IWUSR
+#include <time.h> // for time_t
+#include <unistd.h> // for close, unlink, optarg, optind, chown, getopt
+#include <utime.h> // for utimbuf, utime
typedef void(*sig_type) OF((int));
@@ -1000,12 +1002,10 @@ local int get_method()
ifname);
exit_code = ERROR;
return -1;
- } else {
- WARN((stderr,
- "\n%s: %s: decompression OK, trailing garbage ignored\n",
- progname, ifname));
- return -2;
}
+ WARN((stderr, "\n%s: %s: decompression OK, trailing garbage ignored\n",
+ progname, ifname));
+ return -2;
}
/* ========================================================================
diff --git a/bin/gzip/gzip.h b/bin/gzip/gzip.h
index e2dcddfc..6e01f429 100644
--- a/bin/gzip/gzip.h
+++ b/bin/gzip/gzip.h
@@ -19,9 +19,9 @@ typedef char *voidp;
/* I don't like nested includes, but the string and io functions are used
* too often
*/
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
+#include <stdio.h> // for fprintf, FILE
+#include <time.h> // for time_t
+
#define memzero(s, n) memset((voidp)(s), 0, (n))
#define local static
diff --git a/bin/gzip/inflate.c b/bin/gzip/inflate.c
index bf9774f0..af2e1e92 100644
--- a/bin/gzip/inflate.c
+++ b/bin/gzip/inflate.c
@@ -95,15 +95,18 @@
the two sets of lengths.
*/
+#include "stddef.h" // for NULL
+
+#include <stdio.h> // for fprintf, stderr
+#include <string.h> // for memcpy
#ifdef RCSID
static char rcsid[] = "$Id: inflate.c,v 1.1 2002/08/18 00:59:21 hpa Exp $";
#endif
-#include <sys/types.h>
-#include <stdlib.h>
+#include "gzip.h" // for uch, ulg, get_byte, ush, outcnt, OF, flush_window
+
+#include <stdlib.h> // for free, malloc
-#include "tailor.h"
-#include "gzip.h"
#define slide window
/* Huffman code lookup table entry--this entry is four bytes for machines
diff --git a/bin/gzip/trees.c b/bin/gzip/trees.c
index 28d2e236..1b73553d 100644
--- a/bin/gzip/trees.c
+++ b/bin/gzip/trees.c
@@ -53,8 +53,6 @@
*
*/
-#include <ctype.h>
-
#include "tailor.h"
#include "gzip.h"
@@ -307,7 +305,7 @@ local void compress_block OF((ct_data * ltree, ct_data *dtree));
local void set_file_type OF((void));
#ifndef DEBUG
-#define send_code(c, tree) send_bits(tree[c].Code, tree[c].Len)
+#define send_code(c, tree) send_bits((tree)[c].Code, (tree)[c].Len)
/* Send a code of the given tree. c and tree must not have side effects */
#else /* DEBUG */
@@ -326,7 +324,7 @@ local void set_file_type OF((void));
* used.
*/
-#define MAX(a, b) (a >= b ? a : b)
+#define MAX(a, b) ((a) >= (b) ? (a) : (b))
/* the arguments must not have side effects */
/* ===========================================================================
@@ -442,7 +440,7 @@ local void init_block()
*/
#define pqremove(tree, top) \
{ \
- top = heap[SMALLEST]; \
+ (top) = heap[SMALLEST]; \
heap[SMALLEST] = heap[heap_len--]; \
pqdownheap(tree, SMALLEST); \
}
@@ -451,9 +449,9 @@ local void init_block()
* Compares to subtrees, using the tree depth as tie breaker when
* the subtrees have equal frequency. This minimizes the worst case length.
*/
-#define smaller(tree, n, m) \
- (tree[n].Freq < tree[m].Freq || \
- (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
+#define smaller(tree, n, m) \
+ ((tree)[n].Freq < (tree)[m].Freq || \
+ ((tree)[n].Freq == (tree)[m].Freq && depth[n] <= depth[m]))
/* ===========================================================================
* Restore the heap property by moving down the tree starting at node k,
@@ -743,7 +741,8 @@ int max_code; /* and its largest code of non zero frequency */
nextlen = tree[n + 1].Len;
if (++count < max_count && curlen == nextlen) {
continue;
- } else if (count < min_count) {
+ }
+ if (count < min_count) {
bl_tree[curlen].Freq += count;
} else if (curlen != 0) {
if (curlen != prevlen)
@@ -790,7 +789,8 @@ int max_code; /* and its largest code of non zero frequency */
nextlen = tree[n + 1].Len;
if (++count < max_count && curlen == nextlen) {
continue;
- } else if (count < min_count) {
+ }
+ if (count < min_count) {
do {
send_code(curlen, bl_tree);
} while (--count != 0);
diff --git a/bin/gzip/unzip.c b/bin/gzip/unzip.c
index ba259afa..ead7023f 100644
--- a/bin/gzip/unzip.c
+++ b/bin/gzip/unzip.c
@@ -13,12 +13,12 @@
either deflated or stored.
*/
+#include "stddef.h" // for NULL
#ifdef RCSID
static char rcsid[] = "$Id: unzip.c,v 1.1 2002/08/18 00:59:21 hpa Exp $";
#endif
-#include "tailor.h"
-#include "gzip.h"
+#include "gzip.h" // for error, updcrc, ulg, LG, inflate, uch, DEFLATED, OK
/* ===========================================================================
* Unzip in to out. This routine works on gzip files only.
diff --git a/bin/gzip/util.c b/bin/gzip/util.c
index ce580ff9..056f85e9 100644
--- a/bin/gzip/util.c
+++ b/bin/gzip/util.c
@@ -4,21 +4,21 @@
* terms of the GNU General Public License, see the file COPYING.
*/
+#include "stddef.h" // for NULL
+
+#include <stdio.h> // for fprintf, stderr, EOF, perror, FILE
+#include <string.h> // for strspn, strcpy, strcspn, strlen, strrchr
#ifdef RCSID
static char rcsid[] = "$Id: util.c,v 1.1 2002/08/18 00:59:21 hpa Exp $";
#endif
-#include <ctype.h>
-#include <errno.h>
-#include <sys/types.h>
-
-#include "tailor.h"
-
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdlib.h>
+#include "gzip.h" // for insize, outcnt, ulg, abort_gzip, bytes_out, voidp
+#include "tailor.h" // for PATH_SEP, casemap
-#include "gzip.h"
+#include <ctype.h> // for tolower
+#include <errno.h> // for errno
+#include <stdlib.h> // for calloc, free, getenv, malloc
+#include <unistd.h> // for read, write
extern ulg crc_32_tab[]; /* crc table, defined below */
diff --git a/bin/gzip/zip.c b/bin/gzip/zip.c
index 919be412..e373edff 100644
--- a/bin/gzip/zip.c
+++ b/bin/gzip/zip.c
@@ -8,10 +8,7 @@
static char rcsid[] = "$Id: zip.c,v 1.1 2002/08/18 00:59:21 hpa Exp $";
#endif
-#include <ctype.h>
-#include <sys/types.h>
#include <unistd.h>
-#include <fcntl.h>
#include "tailor.h"
#include "gzip.h"