svn commit: r235435 - head/usr.bin/sort

Gabor Kovesdan gabor at FreeBSD.org
Mon May 14 10:06:50 UTC 2012


Author: gabor
Date: Mon May 14 10:06:49 2012
New Revision: 235435
URL: http://svn.freebsd.org/changeset/base/235435

Log:
  - Eliminate initializations if global variables.  Compilers are not
    required to optimize these so it may result in larger binary size.
  
  Pointed out by:	kib

Modified:
  head/usr.bin/sort/bwstring.c
  head/usr.bin/sort/coll.c
  head/usr.bin/sort/file.c
  head/usr.bin/sort/radixsort.c
  head/usr.bin/sort/sort.c

Modified: head/usr.bin/sort/bwstring.c
==============================================================================
--- head/usr.bin/sort/bwstring.c	Mon May 14 09:55:23 2012	(r235434)
+++ head/usr.bin/sort/bwstring.c	Mon May 14 10:06:49 2012	(r235435)
@@ -41,10 +41,10 @@ __FBSDID("$FreeBSD$");
 #include "bwstring.h"
 #include "sort.h"
 
-bool byte_sort = false;
+bool byte_sort;
 
-static wchar_t **wmonths = NULL;
-static unsigned char **cmonths = NULL;
+static wchar_t **wmonths;
+static unsigned char **cmonths;
 
 /* initialise months */
 

Modified: head/usr.bin/sort/coll.c
==============================================================================
--- head/usr.bin/sort/coll.c	Mon May 14 09:55:23 2012	(r235434)
+++ head/usr.bin/sort/coll.c	Mon May 14 10:06:49 2012	(r235435)
@@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$");
 #include "coll.h"
 #include "vsort.h"
 
-struct key_specs *keys = NULL;
+struct key_specs *keys;
 size_t keys_num = 0;
 
 wchar_t symbol_decimal_point = L'.';

Modified: head/usr.bin/sort/file.c
==============================================================================
--- head/usr.bin/sort/file.c	Mon May 14 09:55:23 2012	(r235434)
+++ head/usr.bin/sort/file.c	Mon May 14 10:06:49 2012	(r235435)
@@ -54,7 +54,7 @@ unsigned long long free_memory = 1000000
 unsigned long long available_free_memory = 1000000;
 
 const char *tmpdir = "/var/tmp";
-const char* compress_program = NULL;
+const char *compress_program;
 
 size_t max_open_files = 16;
 

Modified: head/usr.bin/sort/radixsort.c
==============================================================================
--- head/usr.bin/sort/radixsort.c	Mon May 14 09:55:23 2012	(r235434)
+++ head/usr.bin/sort/radixsort.c	Mon May 14 10:06:49 2012	(r235435)
@@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$");
 #define SMALL_NODE(sl) ((sl)->tosort_num < 5)
 
 /* are we sorting in reverse order ? */
-static bool reverse_sort = false;
+static bool reverse_sort;
 
 /* sort sub-levels array size */
 static const size_t slsz = 256 * sizeof(struct sort_level*);
@@ -77,14 +77,14 @@ struct level_stack {
 	struct sort_level	 *sl;
 };
 
-static struct level_stack *g_ls = NULL;
+static struct level_stack *g_ls;
 
 #if defined(SORT_THREADS)
 /* stack guarding mutex */
 static pthread_mutex_t g_ls_mutex;
 
 /* counter: how many items are left */
-static size_t sort_left = 0;
+static size_t sort_left;
 /* guarding mutex */
 static pthread_mutex_t sort_left_mutex;
 

Modified: head/usr.bin/sort/sort.c
==============================================================================
--- head/usr.bin/sort/sort.c	Mon May 14 09:55:23 2012	(r235434)
+++ head/usr.bin/sort/sort.c	Mon May 14 10:06:49 2012	(r235435)
@@ -62,10 +62,10 @@ nl_catd catalog;
 #define DEFAULT_RANDOM_SORT_SEED_FILE ("/dev/random")
 #define MAX_DEFAULT_RANDOM_SEED_DATA_SIZE (1024)
 
-static bool need_random = false;
-static const char* random_source = DEFAULT_RANDOM_SORT_SEED_FILE;
-static const void* random_seed = NULL;
-static size_t random_seed_size = 0;
+static bool need_random;
+static const char *random_source = DEFAULT_RANDOM_SORT_SEED_FILE;
+static const void *random_seed;
+static size_t random_seed_size;
 
 MD5_CTX md5_ctx;
 
@@ -98,26 +98,26 @@ const char *nlsstr[] = { "",
 
 struct sort_opts sort_opts_vals;
 
-bool debug_sort = false;
-bool need_hint = false;
+bool debug_sort;
+bool need_hint;
 
 #if defined(SORT_THREADS)
 size_t ncpu = 1;
 size_t nthreads = 1;
 #endif
 
-static bool gnusort_numeric_compatibility = false;
+static bool gnusort_numeric_compatibility;
 
 static struct sort_mods default_sort_mods_object;
 struct sort_mods * const default_sort_mods = &default_sort_mods_object;
 
-static bool print_symbols_on_debug = false;
+static bool print_symbols_on_debug;
 
 /*
  * Arguments from file (when file0-from option is used:
  */
 static int argc_from_file0 = -1;
-static char **argv_from_file0 = NULL;
+static char **argv_from_file0;
 
 /*
  * Placeholder symbols for options which have no single-character equivalent


More information about the svn-src-all mailing list