|
|
4aa97a |
From 1940ca0dff25d02aee10a96282d6166fe4b03331 Mon Sep 17 00:00:00 2001
|
|
|
5f69cc |
From: Karel Zak <kzak@redhat.com>
|
|
|
5f69cc |
Date: Tue, 6 Aug 2019 11:19:13 +0200
|
|
|
4aa97a |
Subject: [PATCH 187/189] misc: cleanup size_t vs. int for
|
|
|
4aa97a |
string_add_to_idarray()
|
|
|
5f69cc |
|
|
|
5f69cc |
The newly backported utils use size_t, but the original code is still
|
|
|
5f69cc |
based on int to count output columns. Let's use int everywhere..
|
|
|
5f69cc |
|
|
|
5f69cc |
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1712768
|
|
|
5f69cc |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
5f69cc |
---
|
|
|
5f69cc |
login-utils/lslogins.c | 8 ++++----
|
|
|
5f69cc |
sys-utils/lsipc.c | 20 ++++++++++----------
|
|
|
5f69cc |
sys-utils/lsmem.c | 11 +++++------
|
|
|
5f69cc |
sys-utils/lsns.c | 10 +++++-----
|
|
|
5f69cc |
sys-utils/wdctl.c | 7 ++++---
|
|
|
5f69cc |
sys-utils/zramctl.c | 8 ++++----
|
|
|
5f69cc |
6 files changed, 32 insertions(+), 32 deletions(-)
|
|
|
5f69cc |
|
|
|
5f69cc |
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
|
|
|
5f69cc |
index 041053625..33d4777e5 100644
|
|
|
5f69cc |
--- a/login-utils/lslogins.c
|
|
|
5f69cc |
+++ b/login-utils/lslogins.c
|
|
|
5f69cc |
@@ -438,8 +438,8 @@ static struct utmp *get_last_wtmp(struct lslogins_control *ctl, const char *user
|
|
|
5f69cc |
|
|
|
5f69cc |
static int require_wtmp(void)
|
|
|
5f69cc |
{
|
|
|
5f69cc |
- size_t i;
|
|
|
5f69cc |
- for (i = 0; i < (size_t) ncolumns; i++)
|
|
|
5f69cc |
+ int i;
|
|
|
5f69cc |
+ for (i = 0; i < ncolumns; i++)
|
|
|
5f69cc |
if (is_wtmp_col(columns[i]))
|
|
|
5f69cc |
return 1;
|
|
|
5f69cc |
return 0;
|
|
|
5f69cc |
@@ -447,8 +447,8 @@ static int require_wtmp(void)
|
|
|
5f69cc |
|
|
|
5f69cc |
static int require_btmp(void)
|
|
|
5f69cc |
{
|
|
|
5f69cc |
- size_t i;
|
|
|
5f69cc |
- for (i = 0; i < (size_t) ncolumns; i++)
|
|
|
5f69cc |
+ int i;
|
|
|
5f69cc |
+ for (i = 0; i < ncolumns; i++)
|
|
|
5f69cc |
if (is_btmp_col(columns[i]))
|
|
|
5f69cc |
return 1;
|
|
|
5f69cc |
return 0;
|
|
|
5f69cc |
diff --git a/sys-utils/lsipc.c b/sys-utils/lsipc.c
|
|
|
5f69cc |
index 0be9d9128..1c2c4b294 100644
|
|
|
5f69cc |
--- a/sys-utils/lsipc.c
|
|
|
5f69cc |
+++ b/sys-utils/lsipc.c
|
|
|
5f69cc |
@@ -194,7 +194,7 @@ static const struct lsipc_coldesc coldescs[] =
|
|
|
5f69cc |
* column twice. That's enough, dynamically allocated array of the columns is
|
|
|
5f69cc |
* unnecessary overkill and over-engineering in this case */
|
|
|
5f69cc |
static int columns[ARRAY_SIZE(coldescs) * 2];
|
|
|
5f69cc |
-static size_t ncolumns;
|
|
|
5f69cc |
+static int ncolumns;
|
|
|
5f69cc |
|
|
|
5f69cc |
static inline size_t err_columns_index(size_t arysz, size_t idx)
|
|
|
5f69cc |
{
|
|
|
5f69cc |
@@ -358,7 +358,7 @@ static struct libscols_table *new_table(struct lsipc_control *ctl)
|
|
|
5f69cc |
static struct libscols_table *setup_table(struct lsipc_control *ctl)
|
|
|
5f69cc |
{
|
|
|
5f69cc |
struct libscols_table *table = new_table(ctl);
|
|
|
5f69cc |
- size_t n;
|
|
|
5f69cc |
+ int n;
|
|
|
5f69cc |
|
|
|
5f69cc |
for (n = 0; n < ncolumns; n++) {
|
|
|
5f69cc |
int flags = coldescs[columns[n]].flag;
|
|
|
5f69cc |
@@ -473,7 +473,7 @@ static void global_set_data(struct libscols_table *tb, const char *resource,
|
|
|
5f69cc |
const char *desc, uintmax_t used, uintmax_t limit, int usage)
|
|
|
5f69cc |
{
|
|
|
5f69cc |
struct libscols_line *ln;
|
|
|
5f69cc |
- size_t n;
|
|
|
5f69cc |
+ int n;
|
|
|
5f69cc |
|
|
|
5f69cc |
ln = scols_table_new_line(tb, NULL);
|
|
|
5f69cc |
if (!ln)
|
|
|
5f69cc |
@@ -545,7 +545,7 @@ static void do_sem(int id, struct lsipc_control *ctl, struct libscols_table *tb)
|
|
|
5f69cc |
return;
|
|
|
5f69cc |
}
|
|
|
5f69cc |
for (semdsp = semds; semdsp->next != NULL || id > -1; semdsp = semdsp->next) {
|
|
|
5f69cc |
- size_t n;
|
|
|
5f69cc |
+ int n;
|
|
|
5f69cc |
ln = scols_table_new_line(tb, NULL);
|
|
|
5f69cc |
|
|
|
5f69cc |
for (n = 0; n < ncolumns; n++) {
|
|
|
5f69cc |
@@ -732,7 +732,7 @@ static void do_msg(int id, struct lsipc_control *ctl, struct libscols_table *tb)
|
|
|
5f69cc |
}
|
|
|
5f69cc |
|
|
|
5f69cc |
for (msgdsp = msgds; msgdsp->next != NULL || id > -1 ; msgdsp = msgdsp->next) {
|
|
|
5f69cc |
- size_t n;
|
|
|
5f69cc |
+ int n;
|
|
|
5f69cc |
ln = scols_table_new_line(tb, NULL);
|
|
|
5f69cc |
|
|
|
5f69cc |
/* no need to call getpwuid() for the same user */
|
|
|
5f69cc |
@@ -888,7 +888,7 @@ static void do_shm(int id, struct lsipc_control *ctl, struct libscols_table *tb)
|
|
|
5f69cc |
}
|
|
|
5f69cc |
|
|
|
5f69cc |
for (shmdsp = shmds; shmdsp->next != NULL || id > -1 ; shmdsp = shmdsp->next) {
|
|
|
5f69cc |
- size_t n;
|
|
|
5f69cc |
+ int n;
|
|
|
5f69cc |
ln = scols_table_new_line(tb, NULL);
|
|
|
5f69cc |
if (!ln)
|
|
|
5f69cc |
err_oom();
|
|
|
5f69cc |
@@ -1073,7 +1073,7 @@ int main(int argc, char *argv[])
|
|
|
5f69cc |
{
|
|
|
5f69cc |
int opt, msg = 0, sem = 0, shm = 0, id = -1;
|
|
|
5f69cc |
int show_time = 0, show_creat = 0, global = 0;
|
|
|
5f69cc |
- size_t i;
|
|
|
5f69cc |
+ int i;
|
|
|
5f69cc |
struct lsipc_control *ctl = xcalloc(1, sizeof(struct lsipc_control));
|
|
|
5f69cc |
static struct libscols_table *tb;
|
|
|
5f69cc |
char *outarg = NULL;
|
|
|
5f69cc |
@@ -1248,7 +1248,7 @@ int main(int argc, char *argv[])
|
|
|
5f69cc |
|
|
|
5f69cc |
if (ctl->outmode == OUT_PRETTY && !(optarg || show_creat || show_time)) {
|
|
|
5f69cc |
/* all columns for lsipc --<RESOURCE> --id <ID> */
|
|
|
5f69cc |
- for (ncolumns = 0, i = 0; i < ARRAY_SIZE(coldescs); i++)
|
|
|
5f69cc |
+ for (ncolumns = 0, i = 0; i < (int) ARRAY_SIZE(coldescs); i++)
|
|
|
5f69cc |
columns[ncolumns++] = i;
|
|
|
5f69cc |
} else {
|
|
|
5f69cc |
if (show_creat) {
|
|
|
5f69cc |
@@ -1264,7 +1264,7 @@ int main(int argc, char *argv[])
|
|
|
5f69cc |
}
|
|
|
5f69cc |
if (shm && show_time) {
|
|
|
5f69cc |
/* keep "COMMAND" as last column */
|
|
|
5f69cc |
- size_t cmd = columns[ncolumns - 1] == COL_COMMAND;
|
|
|
5f69cc |
+ int cmd = columns[ncolumns - 1] == COL_COMMAND;
|
|
|
5f69cc |
|
|
|
5f69cc |
if (cmd)
|
|
|
5f69cc |
ncolumns--;
|
|
|
5f69cc |
@@ -1280,7 +1280,7 @@ int main(int argc, char *argv[])
|
|
|
5f69cc |
}
|
|
|
5f69cc |
|
|
|
5f69cc |
if (outarg && string_add_to_idarray(outarg, columns, ARRAY_SIZE(columns),
|
|
|
5f69cc |
- (int *) &ncolumns, column_name_to_id) < 0)
|
|
|
5f69cc |
+ &ncolumns, column_name_to_id) < 0)
|
|
|
5f69cc |
return EXIT_FAILURE;
|
|
|
5f69cc |
|
|
|
5f69cc |
tb = setup_table(ctl);
|
|
|
5f69cc |
diff --git a/sys-utils/lsmem.c b/sys-utils/lsmem.c
|
|
|
5f69cc |
index aaf7374fc..4f682691d 100644
|
|
|
5f69cc |
--- a/sys-utils/lsmem.c
|
|
|
5f69cc |
+++ b/sys-utils/lsmem.c
|
|
|
5f69cc |
@@ -138,7 +138,7 @@ static struct coldesc coldescs[] = {
|
|
|
5f69cc |
* column twice. That's enough, dynamically allocated array of the columns is
|
|
|
5f69cc |
* unnecessary overkill and over-engineering in this case */
|
|
|
5f69cc |
static int columns[ARRAY_SIZE(coldescs) * 2];
|
|
|
5f69cc |
-static size_t ncolumns;
|
|
|
5f69cc |
+static int ncolumns;
|
|
|
5f69cc |
|
|
|
5f69cc |
static inline size_t err_columns_index(size_t arysz, size_t idx)
|
|
|
5f69cc |
{
|
|
|
5f69cc |
@@ -183,7 +183,7 @@ static int column_name_to_id(const char *name, size_t namesz)
|
|
|
5f69cc |
static inline int get_column_id(int num)
|
|
|
5f69cc |
{
|
|
|
5f69cc |
assert(num >= 0);
|
|
|
5f69cc |
- assert((size_t) num < ncolumns);
|
|
|
5f69cc |
+ assert(num < ncolumns);
|
|
|
5f69cc |
assert(columns[num] < (int) ARRAY_SIZE(coldescs));
|
|
|
5f69cc |
|
|
|
5f69cc |
return columns[num];
|
|
|
5f69cc |
@@ -230,7 +230,7 @@ static void set_split_policy(struct lsmem *l, int cols[], size_t ncols)
|
|
|
5f69cc |
|
|
|
5f69cc |
static void add_scols_line(struct lsmem *lsmem, struct memory_block *blk)
|
|
|
5f69cc |
{
|
|
|
5f69cc |
- size_t i;
|
|
|
5f69cc |
+ int i;
|
|
|
5f69cc |
struct libscols_line *line;
|
|
|
5f69cc |
|
|
|
5f69cc |
line = scols_table_new_line(lsmem->table, NULL);
|
|
|
5f69cc |
@@ -523,8 +523,7 @@ int main(int argc, char **argv)
|
|
|
5f69cc |
}, *lsmem = &_lsmem;
|
|
|
5f69cc |
|
|
|
5f69cc |
const char *outarg = NULL, *splitarg = NULL;
|
|
|
5f69cc |
- int c;
|
|
|
5f69cc |
- size_t i;
|
|
|
5f69cc |
+ int c, i;
|
|
|
5f69cc |
|
|
|
5f69cc |
enum {
|
|
|
5f69cc |
LSMEM_OPT_SUMARRY = CHAR_MAX + 1
|
|
|
5f69cc |
@@ -640,7 +639,7 @@ int main(int argc, char **argv)
|
|
|
5f69cc |
}
|
|
|
5f69cc |
|
|
|
5f69cc |
if (outarg && string_add_to_idarray(outarg, columns, ARRAY_SIZE(columns),
|
|
|
5f69cc |
- (int *) &ncolumns, column_name_to_id) < 0)
|
|
|
5f69cc |
+ &ncolumns, column_name_to_id) < 0)
|
|
|
5f69cc |
return EXIT_FAILURE;
|
|
|
5f69cc |
|
|
|
5f69cc |
/*
|
|
|
5f69cc |
diff --git a/sys-utils/lsns.c b/sys-utils/lsns.c
|
|
|
5f69cc |
index d32756508..74f04dc12 100644
|
|
|
5f69cc |
--- a/sys-utils/lsns.c
|
|
|
5f69cc |
+++ b/sys-utils/lsns.c
|
|
|
5f69cc |
@@ -95,7 +95,7 @@ static const struct colinfo infos[] = {
|
|
|
5f69cc |
};
|
|
|
5f69cc |
|
|
|
5f69cc |
static int columns[ARRAY_SIZE(infos) * 2];
|
|
|
5f69cc |
-static size_t ncolumns;
|
|
|
5f69cc |
+static int ncolumns;
|
|
|
5f69cc |
|
|
|
5f69cc |
enum {
|
|
|
5f69cc |
LSNS_ID_MNT = 0,
|
|
|
5f69cc |
@@ -193,7 +193,7 @@ static int column_name_to_id(const char *name, size_t namesz)
|
|
|
5f69cc |
static inline int get_column_id(int num)
|
|
|
5f69cc |
{
|
|
|
5f69cc |
assert(num >= 0);
|
|
|
5f69cc |
- assert((size_t) num < ncolumns);
|
|
|
5f69cc |
+ assert(num < ncolumns);
|
|
|
5f69cc |
assert(columns[num] < (int) ARRAY_SIZE(infos));
|
|
|
5f69cc |
|
|
|
5f69cc |
return columns[num];
|
|
|
5f69cc |
@@ -444,7 +444,7 @@ static int read_namespaces(struct lsns *ls)
|
|
|
5f69cc |
static void add_scols_line(struct lsns *ls, struct libscols_table *table,
|
|
|
5f69cc |
struct lsns_namespace *ns, struct lsns_process *proc)
|
|
|
5f69cc |
{
|
|
|
5f69cc |
- size_t i;
|
|
|
5f69cc |
+ int i;
|
|
|
5f69cc |
struct libscols_line *line;
|
|
|
5f69cc |
|
|
|
5f69cc |
assert(ns);
|
|
|
5f69cc |
@@ -504,7 +504,7 @@ static void add_scols_line(struct lsns *ls, struct libscols_table *table,
|
|
|
5f69cc |
static struct libscols_table *init_scols_table(struct lsns *ls)
|
|
|
5f69cc |
{
|
|
|
5f69cc |
struct libscols_table *tab;
|
|
|
5f69cc |
- size_t i;
|
|
|
5f69cc |
+ int i;
|
|
|
5f69cc |
|
|
|
5f69cc |
tab = scols_new_table();
|
|
|
5f69cc |
if (!tab) {
|
|
|
5f69cc |
@@ -745,7 +745,7 @@ int main(int argc, char *argv[])
|
|
|
5f69cc |
}
|
|
|
5f69cc |
|
|
|
5f69cc |
if (outarg && string_add_to_idarray(outarg, columns, ARRAY_SIZE(columns),
|
|
|
5f69cc |
- (int *) &ncolumns, column_name_to_id) < 0)
|
|
|
5f69cc |
+ &ncolumns, column_name_to_id) < 0)
|
|
|
5f69cc |
return EXIT_FAILURE;
|
|
|
5f69cc |
|
|
|
5f69cc |
scols_init_debug(0);
|
|
|
5f69cc |
diff --git a/sys-utils/wdctl.c b/sys-utils/wdctl.c
|
|
|
5f69cc |
index 24ec770fb..5e996d0ba 100644
|
|
|
5f69cc |
--- a/sys-utils/wdctl.c
|
|
|
5f69cc |
+++ b/sys-utils/wdctl.c
|
|
|
5f69cc |
@@ -238,7 +238,7 @@ static void add_flag_line(struct tt *tt, struct wdinfo *wd, const struct wdflag
|
|
|
5f69cc |
|
|
|
5f69cc |
static int show_flags(struct wdinfo *wd, int tt_flags, uint32_t wanted)
|
|
|
5f69cc |
{
|
|
|
5f69cc |
- size_t i;
|
|
|
5f69cc |
+ int i;
|
|
|
5f69cc |
int rc = -1;
|
|
|
5f69cc |
struct tt *tt;
|
|
|
5f69cc |
uint32_t flags;
|
|
|
5f69cc |
@@ -251,7 +251,7 @@ static int show_flags(struct wdinfo *wd, int tt_flags, uint32_t wanted)
|
|
|
5f69cc |
}
|
|
|
5f69cc |
|
|
|
5f69cc |
/* define columns */
|
|
|
5f69cc |
- for (i = 0; i < (size_t) ncolumns; i++) {
|
|
|
5f69cc |
+ for (i = 0; i < ncolumns; i++) {
|
|
|
5f69cc |
struct colinfo *col = get_column_info(i);
|
|
|
5f69cc |
|
|
|
5f69cc |
if (!tt_define_column(tt, col->name, col->whint, col->flags)) {
|
|
|
5f69cc |
@@ -264,7 +264,7 @@ static int show_flags(struct wdinfo *wd, int tt_flags, uint32_t wanted)
|
|
|
5f69cc |
* -- one line for each supported flag (option) */
|
|
|
5f69cc |
flags = wd->ident.options;
|
|
|
5f69cc |
|
|
|
5f69cc |
- for (i = 0; i < ARRAY_SIZE(wdflags); i++) {
|
|
|
5f69cc |
+ for (i = 0; i < (int) ARRAY_SIZE(wdflags); i++) {
|
|
|
5f69cc |
if (wanted && !(wanted & wdflags[i].flag))
|
|
|
5f69cc |
; /* ignore */
|
|
|
5f69cc |
else if (flags & wdflags[i].flag)
|
|
|
5f69cc |
@@ -513,6 +513,7 @@ int main(int argc, char *argv[])
|
|
|
5f69cc |
return EXIT_SUCCESS;
|
|
|
5f69cc |
case 'h':
|
|
|
5f69cc |
usage(stdout);
|
|
|
5f69cc |
+ /* fallthrough */
|
|
|
5f69cc |
case 'F':
|
|
|
5f69cc |
noflags = 1;
|
|
|
5f69cc |
break;
|
|
|
5f69cc |
diff --git a/sys-utils/zramctl.c b/sys-utils/zramctl.c
|
|
|
5f69cc |
index c3112d68a..3a558d150 100644
|
|
|
5f69cc |
--- a/sys-utils/zramctl.c
|
|
|
5f69cc |
+++ b/sys-utils/zramctl.c
|
|
|
5f69cc |
@@ -392,7 +392,7 @@ static void fill_table_row(struct libscols_table *tb, struct zram *z)
|
|
|
5f69cc |
{
|
|
|
5f69cc |
static struct libscols_line *ln;
|
|
|
5f69cc |
struct sysfs_cxt *sysfs;
|
|
|
5f69cc |
- size_t i;
|
|
|
5f69cc |
+ int i;
|
|
|
5f69cc |
uint64_t num;
|
|
|
5f69cc |
|
|
|
5f69cc |
assert(tb);
|
|
|
5f69cc |
@@ -408,7 +408,7 @@ static void fill_table_row(struct libscols_table *tb, struct zram *z)
|
|
|
5f69cc |
if (!ln)
|
|
|
5f69cc |
err(EXIT_FAILURE, _("failed to initialize output line"));
|
|
|
5f69cc |
|
|
|
5f69cc |
- for (i = 0; i < (size_t) ncolumns; i++) {
|
|
|
5f69cc |
+ for (i = 0; i < ncolumns; i++) {
|
|
|
5f69cc |
char *str = NULL;
|
|
|
5f69cc |
|
|
|
5f69cc |
switch (get_column_id(i)) {
|
|
|
5f69cc |
@@ -479,7 +479,7 @@ static void fill_table_row(struct libscols_table *tb, struct zram *z)
|
|
|
5f69cc |
static void status(struct zram *z)
|
|
|
5f69cc |
{
|
|
|
5f69cc |
struct libscols_table *tb;
|
|
|
5f69cc |
- size_t i;
|
|
|
5f69cc |
+ int i;
|
|
|
5f69cc |
|
|
|
5f69cc |
scols_init_debug(0);
|
|
|
5f69cc |
|
|
|
5f69cc |
@@ -490,7 +490,7 @@ static void status(struct zram *z)
|
|
|
5f69cc |
scols_table_enable_raw(tb, raw);
|
|
|
5f69cc |
scols_table_enable_noheadings(tb, no_headings);
|
|
|
5f69cc |
|
|
|
5f69cc |
- for (i = 0; i < (size_t) ncolumns; i++) {
|
|
|
5f69cc |
+ for (i = 0; i < ncolumns; i++) {
|
|
|
5f69cc |
const struct colinfo *col = get_column_info(i);
|
|
|
5f69cc |
|
|
|
5f69cc |
if (!scols_table_new_column(tb, col->name, col->whint, col->flags))
|
|
|
5f69cc |
--
|
|
|
5f69cc |
2.21.0
|
|
|
5f69cc |
|