Permalink
Browse files

standardize static strings

Since I never change the characters or reassign the pointers, they
might as well all be static, const char arrays.
  • Loading branch information...
1 parent 07b849f commit dc3687f33a148780522d1eb909a8cd12f2216ed8 @ChrisJohnsen committed Mar 30, 2011
Showing with 8 additions and 8 deletions.
  1. +3 −3 reattach-to-user-namespace.c
  2. +5 −5 test.c
@@ -45,7 +45,7 @@ void * _vprocmgr_move_subset_to_user(uid_t target_user, const char *session_type
void * _vprocmgr_move_subset_to_user(uid_t target_user, const char *session_type); /* 10.5 */
#endif
-static char usage_msg[] = "\n"
+static const char usage_msg[] = "\n"
" Reattach to the per-user bootstrap namespace in its \"Background\"\n"
" session then exec the program with args. If \"-l\" is given,\n"
" rewrite the program's argv[0] so that it starts with a '-'.\n";
@@ -91,13 +91,13 @@ int main(int argc, char *argv[]) {
case 1050:
case 1060:
{
- const char fn[] = "_vprocmgr_move_subset_to_user";
+ static const char fn[] = "_vprocmgr_move_subset_to_user";
void *f;
if (!(f = dlsym(RTLD_NEXT, fn)))
die(2, "unable to find %s: %s", fn, dlerror());
void *r;
- const char bg[] = "Background";
+ static const char bg[] = "Background";
/*
* 10.5 has one fewer args.
* Since we are probably using a caller-cleans-up
View
@@ -95,11 +95,11 @@ static void move_to_user(const char *opt) {
if (!(opt && *opt))
die(3, "move-to-user: requires an option (i.e. move-to-user=10.6)");
- static const char * const move_to_user_fn = "_vprocmgr_move_subset_to_user";
+ static const char move_to_user_fn[] = "_vprocmgr_move_subset_to_user";
void *f = dlsym(RTLD_NEXT, move_to_user_fn);
if (!f) die(3, "unable to find %s: %s", move_to_user_fn, dlerror());
- static const char * const session_type = "Background";
+ static const char session_type[] = "Background";
void *r;
if (!strcmp(opt, "10.5"))
r = ((move_to_user_10_5_f)f)(getuid(), session_type);
@@ -112,7 +112,7 @@ static void move_to_user(const char *opt) {
typedef void *(*detach_from_console_f)(unsigned int flags);
static void detach_from_console(const char *opt UNUSED) {
- static const char * const detach_fn = "_vprocmgr_detach_from_console";
+ static const char detach_fn[] = "_vprocmgr_detach_from_console";
void *f = dlsym(RTLD_NEXT, detach_fn);
if (!f) die(4, "unable to find %s: %s", detach_fn, dlerror());
if (((detach_from_console_f)f)(0) != NULL)
@@ -154,9 +154,9 @@ static int parse_int(const char *str, char **rest_,
typedef int (*session_create_f)(int, int);
static void session_create(const char *opt) {
- static const char * const fw =
+ static const char fw[] =
"/System/Library/Frameworks/Security.framework/Versions/Current/Security";
- static const char * const fn = "SessionCreate";
+ static const char fn[] = "SessionCreate";
if (!(opt && *opt && strchr(opt, ',')))
die(6, "session-createn needs two args (e.g. 0,0)");
char *rest;

0 comments on commit dc3687f

Please sign in to comment.