summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2015-04-01 20:58:13 +0000
committermillert <millert@openbsd.org>2015-04-01 20:58:13 +0000
commitc9bc8d3fa490243181c71725a2b76ed26cd685e6 (patch)
treef1fead574cb4791e5160c1c0608935f7b3c362e5
parentIf strtoul() fails to parse the argument to -k, just pass the (diff)
downloadwireguard-openbsd-c9bc8d3fa490243181c71725a2b76ed26cd685e6.tar.xz
wireguard-openbsd-c9bc8d3fa490243181c71725a2b76ed26cd685e6.zip
Style nits, remove whitespace at the start of a function.
-rw-r--r--usr.bin/sort/bwstring.c21
-rw-r--r--usr.bin/sort/coll.c22
-rw-r--r--usr.bin/sort/file.c26
-rw-r--r--usr.bin/sort/mem.c5
-rw-r--r--usr.bin/sort/radixsort.c4
-rw-r--r--usr.bin/sort/sort.c10
6 files changed, 9 insertions, 79 deletions
diff --git a/usr.bin/sort/bwstring.c b/usr.bin/sort/bwstring.c
index 00b6eb9f509..f2822678a8e 100644
--- a/usr.bin/sort/bwstring.c
+++ b/usr.bin/sort/bwstring.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bwstring.c,v 1.5 2015/03/20 15:55:22 millert Exp $ */
+/* $OpenBSD: bwstring.c,v 1.6 2015/04/01 20:58:13 millert Exp $ */
/*-
* Copyright (C) 2009 Gabor Kovesdan <gabor@FreeBSD.org>
@@ -143,7 +143,6 @@ wide_str_coll(const wchar_t *s1, const wchar_t *s2)
void
bwsprintf(FILE *f, struct bwstring *bws, const char *prefix, const char *suffix)
{
-
if (sort_mb_cur_max == 1)
fprintf(f, "%s%s%s", prefix, bws->data.cstr, suffix);
else
@@ -153,21 +152,18 @@ bwsprintf(FILE *f, struct bwstring *bws, const char *prefix, const char *suffix)
const void *
bwsrawdata(const struct bwstring *bws)
{
-
return &(bws->data);
}
size_t
bwsrawlen(const struct bwstring *bws)
{
-
return (sort_mb_cur_max == 1) ? bws->len : SIZEOF_WCHAR_STRING(bws->len);
}
size_t
bws_memsize(const struct bwstring *bws)
{
-
return (sort_mb_cur_max == 1) ? (bws->len + 2 + sizeof(struct bwstring)) :
(SIZEOF_WCHAR_STRING(bws->len + 1) + sizeof(struct bwstring));
}
@@ -175,7 +171,6 @@ bws_memsize(const struct bwstring *bws)
void
bws_setlen(struct bwstring *bws, size_t newlen)
{
-
if (bws && newlen != bws->len && newlen <= bws->len) {
bws->len = newlen;
if (sort_mb_cur_max == 1)
@@ -235,7 +230,6 @@ bwsdup(const struct bwstring *s)
struct bwstring *
bwssbdup(const wchar_t *str, size_t len)
{
-
if (str == NULL)
return (len == 0) ? bwsalloc(0) : NULL;
else {
@@ -317,7 +311,6 @@ bwscsbdup(const unsigned char *str, size_t len)
void
bwsfree(struct bwstring *s)
{
-
sort_free(s);
}
@@ -387,7 +380,6 @@ struct bwstring *
bwsnocpy(struct bwstring *dst, const struct bwstring *src, size_t offset,
size_t size)
{
-
if (offset >= src->len) {
dst->data.wstr[0] = 0;
dst->len = 0;
@@ -420,7 +412,6 @@ bwsnocpy(struct bwstring *dst, const struct bwstring *src, size_t offset,
size_t
bwsfwrite(struct bwstring *bws, FILE *f, bool zero_ended)
{
-
if (sort_mb_cur_max == 1) {
size_t len = bws->len;
@@ -525,7 +516,7 @@ bwsfgetln(FILE *f, size_t *len, bool zero_ended, struct reader_buffer *rb)
}
rb->fgetwln_z_buffer[*len] = 0;
- if (sort_mb_cur_max == 1)
+ if (sort_mb_cur_max == 1) {
while (!feof(f)) {
int c;
@@ -549,7 +540,7 @@ bwsfgetln(FILE *f, size_t *len, bool zero_ended, struct reader_buffer *rb)
rb->fgetwln_z_buffer[*len] = c;
rb->fgetwln_z_buffer[++(*len)] = 0;
}
- else
+ } else {
while (!feof(f)) {
wint_t c = 0;
@@ -573,6 +564,7 @@ bwsfgetln(FILE *f, size_t *len, bool zero_ended, struct reader_buffer *rb)
rb->fgetwln_z_buffer[*len] = c;
rb->fgetwln_z_buffer[++(*len)] = 0;
}
+ }
line_read_done:
/* we do not count the last 0 */
@@ -904,11 +896,9 @@ bwstod(struct bwstring *s0, bool *empty)
* a month name, it returns (number of the month - 1),
* while if there is no match, it just return -1.
*/
-
int
bws_month_score(const struct bwstring *s0)
{
-
if (sort_mb_cur_max == 1) {
const char *end, *s;
int i;
@@ -949,7 +939,6 @@ bws_month_score(const struct bwstring *s0)
struct bwstring *
ignore_leading_blanks(struct bwstring *str)
{
-
if (sort_mb_cur_max == 1) {
unsigned char *dst, *end, *src;
@@ -1109,7 +1098,6 @@ dictionary_order(struct bwstring *str)
struct bwstring *
ignore_case(struct bwstring *str)
{
-
if (sort_mb_cur_max == 1) {
unsigned char *end, *s;
@@ -1137,7 +1125,6 @@ ignore_case(struct bwstring *str)
void
bws_disorder_warnx(struct bwstring *s, const char *fn, size_t pos)
{
-
if (sort_mb_cur_max == 1)
warnx("%s:%zu: disorder: %s", fn, pos + 1, s->data.cstr);
else
diff --git a/usr.bin/sort/coll.c b/usr.bin/sort/coll.c
index 042c4d7bb33..7138291d07c 100644
--- a/usr.bin/sort/coll.c
+++ b/usr.bin/sort/coll.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: coll.c,v 1.3 2015/03/29 18:47:19 miod Exp $ */
+/* $OpenBSD: coll.c,v 1.4 2015/04/01 20:58:13 millert Exp $ */
/*-
* Copyright (C) 2009 Gabor Kovesdan <gabor@FreeBSD.org>
@@ -81,7 +81,6 @@ keys_array_alloc(void)
static size_t
key_hint_size(void)
{
-
return need_hint ? sizeof(struct key_hint) : 0;
}
@@ -91,7 +90,6 @@ key_hint_size(void)
size_t
keys_array_size(void)
{
-
return keys_num * (sizeof(struct key_value) + key_hint_size());
}
@@ -101,7 +99,6 @@ keys_array_size(void)
void
clean_keys_array(const struct bwstring *s, struct keys_array *ka)
{
-
if (ka) {
size_t i;
@@ -118,7 +115,6 @@ clean_keys_array(const struct bwstring *s, struct keys_array *ka)
void
set_key_on_keys_array(struct keys_array *ka, struct bwstring *s, size_t ind)
{
-
if (ka && keys_num > ind) {
struct key_value *kv;
@@ -172,7 +168,6 @@ sort_list_item_size(struct sort_list_item *si)
static void
sort_list_item_make_key(struct sort_list_item *si)
{
-
preproc(si->str, &(si->ka));
}
@@ -183,7 +178,6 @@ sort_list_item_make_key(struct sort_list_item *si)
void
sort_list_item_set(struct sort_list_item *si, struct bwstring *str)
{
-
if (si) {
clean_keys_array(si->str, &(si->ka));
if (si->str) {
@@ -206,7 +200,6 @@ sort_list_item_set(struct sort_list_item *si, struct bwstring *str)
void
sort_list_item_clean(struct sort_list_item *si)
{
-
if (si) {
clean_keys_array(si->str, &(si->ka));
if (si->str) {
@@ -247,7 +240,6 @@ skip_cols_to_start(const struct bwstring *s, size_t cols, size_t start,
static size_t
skip_fields_to_start(const struct bwstring *s, size_t fields, bool *empty_field)
{
-
if (fields < 2) {
if (BWSLEN(s) == 0)
*empty_field = true;
@@ -296,7 +288,6 @@ static void
find_field_start(const struct bwstring *s, struct key_specs *ks,
size_t *field_start, size_t *key_start, bool *empty_field, bool *empty_key)
{
-
*field_start = skip_fields_to_start(s, ks->f1, empty_field);
if (!*empty_field)
*key_start = skip_cols_to_start(s, ks->c1, *field_start,
@@ -391,7 +382,6 @@ cut_field(const struct bwstring *s, struct key_specs *ks)
int
preproc(struct bwstring *s, struct keys_array *ka)
{
-
if (sort_opts_vals.kflag) {
size_t i;
for (i = 0; i < keys_num; i++) {
@@ -447,7 +437,6 @@ preproc(struct bwstring *s, struct keys_array *ka)
cmpcoll_t
get_sort_func(struct sort_mods *sm)
{
-
if (sm->nflag)
return numcoll;
else if (sm->hflag)
@@ -501,7 +490,6 @@ key_coll(struct keys_array *ps1, struct keys_array *ps2, size_t offset)
int
top_level_str_coll(const struct bwstring *s1, const struct bwstring *s2)
{
-
if (default_sort_mods->rflag) {
const struct bwstring *tmp;
@@ -590,7 +578,6 @@ list_coll_offset(struct sort_list_item **ss1, struct sort_list_item **ss2,
int
list_coll(const void *ss1, const void *ss2)
{
-
return list_coll_offset((struct sort_list_item **)ss1,
(struct sort_list_item **)ss2, 0);
}
@@ -647,7 +634,6 @@ get_list_call_func(size_t offset)
int
list_coll_by_str_only(struct sort_list_item **ss1, struct sort_list_item **ss2)
{
-
return top_level_str_coll(((*ss1)->str), ((*ss2)->str));
}
@@ -786,7 +772,6 @@ wstrcoll(struct key_value *kv1, struct key_value *kv2, size_t offset)
static inline int
cmpsuffix(unsigned char si1, unsigned char si2)
{
-
return (char)si1 - (char)si2;
}
@@ -951,7 +936,6 @@ numcoll_impl(struct key_value *kv1, struct key_value *kv2,
static int
numcoll(struct key_value *kv1, struct key_value *kv2, size_t offset)
{
-
return numcoll_impl(kv1, kv2, offset, false);
}
@@ -961,7 +945,6 @@ numcoll(struct key_value *kv1, struct key_value *kv2, size_t offset)
static int
hnumcoll(struct key_value *kv1, struct key_value *kv2, size_t offset)
{
-
return numcoll_impl(kv1, kv2, offset, true);
}
@@ -1047,7 +1030,6 @@ versioncoll(struct key_value *kv1, struct key_value *kv2,
static inline bool
huge_minus(double d, int err1)
{
-
if (err1 == ERANGE)
if (d == -HUGE_VAL || d == -HUGE_VALF || d == -HUGE_VALL)
return 1;
@@ -1061,7 +1043,6 @@ huge_minus(double d, int err1)
static inline bool
huge_plus(double d, int err1)
{
-
if (err1 == ERANGE)
if (d == HUGE_VAL || d == HUGE_VALF || d == HUGE_VALL)
return 1;
@@ -1088,7 +1069,6 @@ is_nan(double d)
static int
cmp_nans(double d1, double d2)
{
-
if (d1 == d2)
return 0;
return d1 < d2 ? -1 : 1;
diff --git a/usr.bin/sort/file.c b/usr.bin/sort/file.c
index e8f1d924d9b..efc0312f8c2 100644
--- a/usr.bin/sort/file.c
+++ b/usr.bin/sort/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.7 2015/04/01 20:17:56 tobias Exp $ */
+/* $OpenBSD: file.c,v 1.8 2015/04/01 20:58:13 millert Exp $ */
/*-
* Copyright (C) 2009 Gabor Kovesdan <gabor@FreeBSD.org>
@@ -106,7 +106,6 @@ static LIST_HEAD(CLEANABLE_FILES, CLEANABLE_FILE) tmp_files;
void
init_tmp_files(void)
{
-
LIST_INIT(&tmp_files);
}
@@ -116,7 +115,6 @@ init_tmp_files(void)
void
tmp_file_atexit(const char *tmp_file)
{
-
if (tmp_file) {
struct CLEANABLE_FILE *item =
sort_malloc(sizeof(struct CLEANABLE_FILE));
@@ -184,7 +182,6 @@ new_tmp_file_name(void)
void
file_list_init(struct file_list *fl, bool tmp)
{
-
if (fl) {
fl->count = 0;
fl->sz = 0;
@@ -199,7 +196,6 @@ file_list_init(struct file_list *fl, bool tmp)
void
file_list_add(struct file_list *fl, char *fn, bool allocate)
{
-
if (fl && fn) {
if (fl->count >= fl->sz || fl->fns == NULL) {
fl->sz = fl->sz * 2 + 1;
@@ -217,7 +213,6 @@ file_list_add(struct file_list *fl, char *fn, bool allocate)
void
file_list_populate(struct file_list *fl, int argc, char **argv, bool allocate)
{
-
if (fl && argv) {
int i;
@@ -233,7 +228,6 @@ file_list_populate(struct file_list *fl, int argc, char **argv, bool allocate)
void
file_list_clean(struct file_list *fl)
{
-
if (fl) {
if (fl->fns) {
size_t i;
@@ -261,7 +255,6 @@ file_list_clean(struct file_list *fl)
void
sort_list_init(struct sort_list *l)
{
-
if (l) {
l->count = 0;
l->size = 0;
@@ -276,7 +269,6 @@ sort_list_init(struct sort_list *l)
void
sort_list_add(struct sort_list *l, struct bwstring *str)
{
-
if (l && str) {
size_t indx = l->count;
@@ -302,7 +294,6 @@ sort_list_add(struct sort_list *l, struct bwstring *str)
void
sort_list_clean(struct sort_list *l)
{
-
if (l) {
if (l->list) {
size_t i;
@@ -333,7 +324,6 @@ sort_list_clean(struct sort_list *l)
void
sort_list_dump(struct sort_list *l, const char *fn)
{
-
if (l && fn) {
FILE *f;
@@ -749,7 +739,6 @@ file_reader_readline(struct file_reader *fr)
static void
file_reader_clean(struct file_reader *fr)
{
-
if (fr) {
if (fr->mmapaddr)
munmap(fr->mmapaddr, fr->mmapsize);
@@ -774,7 +763,6 @@ file_reader_clean(struct file_reader *fr)
void
file_reader_free(struct file_reader *fr)
{
-
if (fr) {
file_reader_clean(fr);
sort_free(fr);
@@ -822,7 +810,6 @@ procfile(const char *fsrc, struct sort_list *list, struct file_list *fl)
static int
file_header_cmp(struct file_header *f1, struct file_header *f2)
{
-
if (f1 == f2)
return 0;
else {
@@ -847,7 +834,6 @@ file_header_cmp(struct file_header *f1, struct file_header *f2)
static void
file_header_init(struct file_header **fh, const char *fn, size_t file_pos)
{
-
if (fh && fn) {
struct bwstring *line;
@@ -876,7 +862,6 @@ file_header_init(struct file_header **fh, const char *fn, size_t file_pos)
static void
file_header_close(struct file_header **fh)
{
-
if (fh && *fh) {
if ((*fh)->fr) {
file_reader_free((*fh)->fr);
@@ -914,7 +899,6 @@ file_header_swap(struct file_header **fh, size_t i1, size_t i2)
static void
file_header_heap_swim(struct file_header **fh, size_t indx)
{
-
if (indx > 0) {
size_t parent_index;
@@ -964,7 +948,6 @@ file_header_heap_sink(struct file_header **fh, size_t indx, size_t size)
static void
file_header_list_rearrange_from_header(struct file_header **fh, size_t size)
{
-
file_header_heap_sink(fh, 0, size);
}
@@ -974,7 +957,6 @@ file_header_list_rearrange_from_header(struct file_header **fh, size_t size)
static void
file_header_list_push(struct file_header *f, struct file_header **fh, size_t size)
{
-
fh[size++] = f;
file_header_heap_swim(fh, size - 1);
}
@@ -990,7 +972,6 @@ struct last_printed
static void
file_header_print(struct file_header *fh, FILE *f_out, struct last_printed *lp)
{
-
if (fh && fh->fr && f_out && fh->si && fh->si->str) {
if (sort_opts_vals.uflag) {
if ((lp->str == NULL) || (str_list_coll(lp->str, &(fh->si)))) {
@@ -1010,7 +991,6 @@ file_header_print(struct file_header *fh, FILE *f_out, struct last_printed *lp)
static void
file_header_read_next(struct file_header *fh)
{
-
if (fh && fh->fr) {
struct bwstring *tmp;
@@ -1068,7 +1048,6 @@ file_headers_merge(size_t fnum, struct file_header **fh, FILE *f_out)
static void
merge_files_array(size_t argc, char **argv, const char *fn_out)
{
-
if (argv && fn_out) {
struct file_header **fh;
FILE *f_out;
@@ -1101,7 +1080,6 @@ merge_files_array(size_t argc, char **argv, const char *fn_out)
static int
shrink_file_list(struct file_list *fl)
{
-
if (fl == NULL || (size_t)fl->count < max_open_files)
return 0;
else {
@@ -1146,7 +1124,6 @@ shrink_file_list(struct file_list *fl)
void
merge_files(struct file_list *fl, const char *fn_out)
{
-
if (fl && fn_out) {
while (shrink_file_list(fl));
@@ -1157,7 +1134,6 @@ merge_files(struct file_list *fl, const char *fn_out)
static const char *
get_sort_method_name(int sm)
{
-
if (sm == SORT_MERGESORT)
return "mergesort";
else if (sort_opts_vals.sort_method == SORT_RADIXSORT)
diff --git a/usr.bin/sort/mem.c b/usr.bin/sort/mem.c
index a38bf13bb9a..17f9af0633a 100644
--- a/usr.bin/sort/mem.c
+++ b/usr.bin/sort/mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mem.c,v 1.3 2015/03/30 19:57:36 millert Exp $ */
+/* $OpenBSD: mem.c,v 1.4 2015/04/01 20:58:13 millert Exp $ */
/*-
* Copyright (C) 2009 Gabor Kovesdan <gabor@FreeBSD.org>
@@ -66,7 +66,6 @@ sort_calloc(size_t nmemb, size_t size)
void
sort_free(void *ptr)
{
-
free(ptr);
}
@@ -76,7 +75,6 @@ sort_free(void *ptr)
void *
sort_realloc(void *ptr, size_t size)
{
-
if ((ptr = realloc(ptr, size)) == NULL)
err(2, NULL);
return ptr;
@@ -88,7 +86,6 @@ sort_realloc(void *ptr, size_t size)
void *
sort_reallocarray(void *ptr, size_t nmemb, size_t size)
{
-
if ((ptr = reallocarray(ptr, nmemb, size)) == NULL)
err(2, NULL);
return ptr;
diff --git a/usr.bin/sort/radixsort.c b/usr.bin/sort/radixsort.c
index 59f65ace16c..bc68e45a5cd 100644
--- a/usr.bin/sort/radixsort.c
+++ b/usr.bin/sort/radixsort.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: radixsort.c,v 1.2 2015/03/17 17:49:27 millert Exp $ */
+/* $OpenBSD: radixsort.c,v 1.3 2015/04/01 20:58:13 millert Exp $ */
/*-
* Copyright (C) 2012 Oleg Moskalenko <mom040267@gmail.com>
@@ -138,7 +138,6 @@ add_to_sublevel(struct sort_level *sl, struct sort_list_item *item, size_t indx)
static inline void
add_leaf(struct sort_level *sl, struct sort_list_item *item)
{
-
if (++(sl->leaves_num) > sl->leaves_sz) {
sl->leaves_sz = sl->leaves_num + 128;
sl->leaves = sort_reallocarray(sl->leaves, sl->leaves_sz,
@@ -177,7 +176,6 @@ place_item(struct sort_level *sl, size_t item)
static void
free_sort_level(struct sort_level *sl)
{
-
if (sl) {
if (sl->leaves)
sort_free(sl->leaves);
diff --git a/usr.bin/sort/sort.c b/usr.bin/sort/sort.c
index 88f99c9768b..6fab6aaefe1 100644
--- a/usr.bin/sort/sort.c
+++ b/usr.bin/sort/sort.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sort.c,v 1.58 2015/04/01 20:28:04 millert Exp $ */
+/* $OpenBSD: sort.c,v 1.59 2015/04/01 20:58:13 millert Exp $ */
/*-
* Copyright (C) 2009 Gabor Kovesdan <gabor@FreeBSD.org>
@@ -143,7 +143,6 @@ static const struct option long_options[] = {
static bool
sort_modifier_empty(struct sort_mods *sm)
{
-
if (sm == NULL)
return true;
return !(sm->Mflag || sm->Vflag || sm->nflag || sm->gflag ||
@@ -156,7 +155,6 @@ sort_modifier_empty(struct sort_mods *sm)
static __dead void
usage(int exit_val)
{
-
fprintf(exit_val ? stderr : stdout,
"usage: %s [-bCcdfgHhiMmnRrsuVz] [-k field1[,field2]] [-o output] "
"[-S size]\n\t[-T dir] [-t char] [file ...]\n", getprogname());
@@ -242,7 +240,6 @@ set_hw_params(void)
static void
conv_mbtowc(wchar_t *wc, const char *c, const wchar_t def)
{
-
if (wc && c) {
int res;
@@ -324,7 +321,6 @@ set_tmpdir(void)
static unsigned long long
parse_memory_buffer_value(const char *value)
{
-
if (value == NULL)
return available_free_memory;
else {
@@ -382,7 +378,6 @@ parse_memory_buffer_value(const char *value)
static void
sig_handler(int sig __unused)
{
-
clear_tmp_files();
_exit(2);
}
@@ -416,7 +411,6 @@ set_signal_handler(void)
static void
unknown(const char *what)
{
-
errx(2, "Unknown feature: %s", what);
}
@@ -457,7 +451,6 @@ check_mutually_exclusive_flags(char c, bool *mef_flags)
static void
set_sort_opts(void)
{
-
memset(&default_sort_mods_object, 0,
sizeof(default_sort_mods_object));
memset(&sort_opts_vals, 0, sizeof(sort_opts_vals));
@@ -471,7 +464,6 @@ set_sort_opts(void)
static bool
set_sort_modifier(struct sort_mods *sm, int c)
{
-
if (sm) {
switch (c){
case 'b':