Skip to content

Commit b62347c

Browse files
committed
convert into static declarations where possible
1 parent ad08952 commit b62347c

13 files changed

+70
-73
lines changed

include/palerain.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,9 @@ boyermoore_horspool_memmem(const unsigned char* haystack, size_t hlen,
204204
const unsigned char* needle, size_t nlen);
205205

206206

207-
extern void* pongo_usb_callback(stuff_t* arg);
208207
usb_ret_t USBControlTransfer(usb_device_handle_t handle, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint32_t wLength, void *data, uint32_t *wLenDone);
209208
const char *usb_strerror(usb_ret_t err);
210209
int wait_for_pongo(void);
211-
int upload_pongo_file(usb_device_handle_t, unsigned char*, unsigned int);
212-
int issue_pongo_command(usb_device_handle_t, char*);
213210
int tui(void);
214211
int optparse(int argc, char* argv[]);
215212

@@ -221,7 +218,6 @@ bool set_found_pongo(bool val);
221218
uint64_t get_ecid_wait_for_dfu(void);
222219
uint64_t set_ecid_wait_for_dfu(uint64_t ecid);
223220

224-
void write_stdout(char *buf, uint32_t len);
225221
void io_start(stuff_t *stuff);
226222
void io_stop(stuff_t *stuff);
227223

include/tui.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,9 @@ void tui_draw_rectangle(int x1, int y1, int x2, int y2);
102102
#define TUI_VERSION "Unknown Version"
103103
#endif
104104

105-
extern int tui_state;
106105
extern int tui_x_offset;
107106
extern int tui_y_offset;
108107

109-
extern bool tui_can_start;
110-
111108
extern int tui_mouse_x;
112109
extern int tui_mouse_y;
113110

@@ -167,8 +164,6 @@ struct tui_connected_device {
167164

168165
extern struct tui_connected_device *tui_connected_devices;
169166

170-
int tui_compare_versions(const char *firstVersion, const char *secondVersion);
171-
172167
void tui_jailbreak(void);
173168
extern bool tui_is_jailbreaking;
174169
extern int tui_jailbreak_stage;
@@ -179,7 +174,6 @@ void tui_jailbreak_status_changed(void);
179174
extern bool tui_is_restarting;
180175
void tui_terminate(int sig);
181176

182-
extern bool tui_options_allow_untested;
183177
extern bool tui_options_safe_mode;
184178
extern bool tui_options_verbose_boot;
185179
extern bool tui_options_force_revert;

src/dfuhelper.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
int dfuhelper_thr_running = false;
4242

43-
void step(int time, int time2, char *text, bool (*cond)(uint64_t), uint64_t cond_arg) {
43+
static void step(int time, int time2, char *text, bool (*cond)(uint64_t), uint64_t cond_arg) {
4444
for (int i = time2; i < time; i++) {
4545
printf(
4646
(palerain_flags & palerain_option_no_colors)
@@ -59,7 +59,7 @@ void step(int time, int time2, char *text, bool (*cond)(uint64_t), uint64_t cond
5959
if (time2 == 0) puts("");
6060
}
6161

62-
int connected_normal_mode(const usbmuxd_device_info_t *usbmuxd_device) {
62+
static int connected_normal_mode(const usbmuxd_device_info_t *usbmuxd_device) {
6363
devinfo_t dev;
6464
int ret;
6565
ret = devinfo_cmd(&dev, usbmuxd_device->udid);
@@ -133,7 +133,7 @@ static bool conditional(uint64_t ecid) {
133133
return get_ecid_wait_for_dfu() != ecid;
134134
}
135135

136-
void* connected_recovery_mode(struct irecv_device_info* info) {
136+
static void* connected_recovery_mode(struct irecv_device_info* info) {
137137
int ret;
138138
uint64_t ecid;
139139
uint32_t cpid, bdid;
@@ -223,7 +223,7 @@ void* connected_recovery_mode(struct irecv_device_info* info) {
223223
return NULL;
224224
}
225225

226-
void* connected_dfu_mode(struct irecv_device_info* info) {
226+
static void* connected_dfu_mode(struct irecv_device_info* info) {
227227
if (get_ecid_wait_for_dfu() == info->ecid) {
228228
set_ecid_wait_for_dfu(0);
229229
puts("");
@@ -240,7 +240,7 @@ void* connected_dfu_mode(struct irecv_device_info* info) {
240240
return NULL;
241241
}
242242

243-
void device_event_cb(const usbmuxd_event_t *event, void* userdata) {
243+
static void device_event_cb(const usbmuxd_event_t *event, void* userdata) {
244244
if (event->device.conn_type != CONNECTION_TYPE_USB) return;
245245
switch (event->event) {
246246
case UE_DEVICE_ADD:
@@ -265,7 +265,7 @@ void device_event_cb(const usbmuxd_event_t *event, void* userdata) {
265265
}
266266
}
267267

268-
void irecv_device_event_cb(const irecv_device_event_t *event, void* userdata) {
268+
static void irecv_device_event_cb(const irecv_device_event_t *event, void* userdata) {
269269
pthread_t recovery_thread, dfu_thread;
270270
int ret;
271271

src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void thr_cleanup(void* ptr) {
5757
*(int*)ptr = 0;
5858
}
5959

60-
int build_checks(void) {
60+
static int build_checks(void) {
6161
#ifndef NO_CHECKRAIN
6262
#if defined(__APPLE__)
6363
struct mach_header_64* c1_header = (struct mach_header_64*)&checkra1n[0];
@@ -96,7 +96,7 @@ int saved_argc;
9696
char** saved_argv;
9797
char** saved_envp;
9898

99-
int palera1n(int argc, char *argv[], char *envp[]) {
99+
static int palera1n(int argc, char *argv[], char *envp[]) {
100100
saved_argc = argc;
101101
saved_argv = argv;
102102
saved_envp = envp;

src/override_file.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <sys/mman.h>
1515
#include <errno.h>
1616

17-
1817
int override_file(override_file_t *finfo, niarelap_file_t** orig, unsigned int *orig_len, char *filename) {
1918
int ret = 0;
2019
int fd = open(filename, O_RDONLY);

src/pongo_helper.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ int pongo_thr_running = 0;
2121

2222
#define ERR(...) LOG(LOG_VERBOSE, __VA_ARGS__)
2323

24+
static int issue_pongo_command(usb_device_handle_t, char*);
25+
static int upload_pongo_file(usb_device_handle_t, unsigned char*, unsigned int);
26+
static void write_stdout(char *buf, uint32_t len);
27+
2428
void* pongo_helper(void* ptr) {
2529
pongo_thr_running = 1;
2630
pthread_cleanup_push(thr_cleanup, &pongo_thr_running);
@@ -32,7 +36,7 @@ void* pongo_helper(void* ptr) {
3236
return NULL;
3337
}
3438

35-
void *pongo_usb_callback(stuff_t *arg) {
39+
static void *pongo_usb_callback(stuff_t *arg) {
3640
if (get_found_pongo())
3741
return NULL;
3842
set_found_pongo(1);
@@ -145,7 +149,7 @@ void *pongo_usb_callback(stuff_t *arg) {
145149
return NULL;
146150
}
147151

148-
int issue_pongo_command(usb_device_handle_t handle, char *command)
152+
static int issue_pongo_command(usb_device_handle_t handle, char *command)
149153
{
150154
uint32_t outpos = 0;
151155
uint32_t outlen = 0;
@@ -207,7 +211,7 @@ int issue_pongo_command(usb_device_handle_t handle, char *command)
207211
return ret;
208212
}
209213

210-
int upload_pongo_file(usb_device_handle_t handle, unsigned char *buf, unsigned int buf_len)
214+
static int upload_pongo_file(usb_device_handle_t handle, unsigned char *buf, unsigned int buf_len)
211215
{
212216
int ret = 0;
213217
ret = USBControlTransfer(handle, 0x21, 1, 0, 0, 4, &buf_len, NULL);
@@ -263,7 +267,7 @@ void io_stop(stuff_t *stuff)
263267
#endif
264268
}
265269

266-
void write_stdout(char *buf, uint32_t len)
270+
static void write_stdout(char *buf, uint32_t len)
267271
{
268272
while(len > 0) {
269273
if (verbose >= 3) {

src/tui_devhelper.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <palerain.h>
44
#include <tui.h>
55

6-
irecv_device_t tui_get_recovery_device(uint64_t ecid) {
6+
static irecv_device_t tui_get_recovery_device(uint64_t ecid) {
77
irecv_client_t client = NULL;
88
for (int i = 0; i <= 5; i++) {
99
irecv_error_t err = irecv_open_with_ecid(&client, ecid);
@@ -28,39 +28,39 @@ irecv_device_t tui_get_recovery_device(uint64_t ecid) {
2828

2929
struct tui_connected_device *tui_connected_devices = NULL;
3030

31-
void* tui_connected_recovery_mode(struct irecv_device_info* info) {
31+
static void* tui_connected_recovery_mode(struct irecv_device_info* info) {
3232
//printf("Recovery mode device %" PRIu64 " connected\n", info->ecid);
3333
tui_last_event = TUI_EVENT_CONNECTED_DEVICES_CHANGED;
3434
sem_post(tui_event_semaphore);
3535
pthread_exit(NULL);
3636
return NULL;
3737
}
3838

39-
void* tui_disconnected_recovery_mode(struct irecv_device_info* info) {
39+
static void* tui_disconnected_recovery_mode(struct irecv_device_info* info) {
4040
//printf("Recovery mode device %" PRIu64 " disconnected\n", info->ecid);
4141
tui_last_event = TUI_EVENT_CONNECTED_DEVICES_CHANGED;
4242
sem_post(tui_event_semaphore);
4343
pthread_exit(NULL);
4444
return NULL;
4545
}
4646

47-
void* tui_connected_dfu_mode(struct irecv_device_info* info) {
47+
static void* tui_connected_dfu_mode(struct irecv_device_info* info) {
4848
//printf("DFU mode device %" PRIu64 " connected\n", info->ecid);
4949
tui_last_event = TUI_EVENT_CONNECTED_DEVICES_CHANGED;
5050
sem_post(tui_event_semaphore);
5151
pthread_exit(NULL);
5252
return NULL;
5353
}
5454

55-
void* tui_disconnected_dfu_mode(struct irecv_device_info* info) {
55+
static void* tui_disconnected_dfu_mode(struct irecv_device_info* info) {
5656
//printf("DFU mode device %" PRIu64 " disconnected\n", info->ecid);
5757
tui_last_event = TUI_EVENT_CONNECTED_DEVICES_CHANGED;
5858
sem_post(tui_event_semaphore);
5959
pthread_exit(NULL);
6060
return NULL;
6161
}
6262

63-
int tui_connected_normal_mode(const usbmuxd_device_info_t *usbmuxd_device) {
63+
static int tui_connected_normal_mode(const usbmuxd_device_info_t *usbmuxd_device) {
6464
struct tui_connected_device *tui_dev = malloc(sizeof(struct tui_connected_device));
6565
strcpy(tui_dev->udid, usbmuxd_device->udid);
6666
tui_dev->next = tui_connected_devices;
@@ -105,7 +105,7 @@ int tui_connected_normal_mode(const usbmuxd_device_info_t *usbmuxd_device) {
105105
return 0;
106106
}
107107

108-
void tui_disconnected_normal_mode(const usbmuxd_device_info_t *usbmuxd_device) {
108+
static void tui_disconnected_normal_mode(const usbmuxd_device_info_t *usbmuxd_device) {
109109
struct tui_connected_device *cur = tui_connected_devices;
110110
struct tui_connected_device *prev = NULL;
111111
while (cur) {
@@ -126,7 +126,7 @@ void tui_disconnected_normal_mode(const usbmuxd_device_info_t *usbmuxd_device) {
126126
sem_post(tui_event_semaphore);
127127
}
128128

129-
void tui_device_event_cb(const usbmuxd_event_t *event, void* userdata) {
129+
static void tui_device_event_cb(const usbmuxd_event_t *event, void* userdata) {
130130
if (event->device.conn_type != CONNECTION_TYPE_USB) return;
131131
switch (event->event) {
132132
case UE_DEVICE_ADD:
@@ -140,7 +140,7 @@ void tui_device_event_cb(const usbmuxd_event_t *event, void* userdata) {
140140
}
141141
}
142142

143-
void tui_irecv_device_event_cb(const irecv_device_event_t *event, void* userdata) {
143+
static void tui_irecv_device_event_cb(const irecv_device_event_t *event, void* userdata) {
144144
pthread_t recovery_thread, dfu_thread;
145145
int ret;
146146

src/tui_main.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ int proc_pidpath(int pid, void * buffer, uint32_t buffersize);
2828
char random_sem_name[sizeof("palera1n.tui_event_semaphore") + 16 + 1];
2929
#endif
3030

31-
int tui_state = 0;
31+
static int tui_state = 0;
32+
3233
int tui_x_offset = 0;
3334
int tui_y_offset = 0;
3435

3536
bool supports_bright_colors = true;
3637

37-
struct termios saved_termios;
38+
static struct termios saved_termios;
3839

3940
int redraw_screen(void) {
4041
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
@@ -83,7 +84,7 @@ int redraw_screen(void) {
8384
return 0;
8485
}
8586

86-
int destroy_window(void) {
87+
static int destroy_window(void) {
8788
if (!tui_started) return 0;
8889
tui_started = false;
8990
tcsetattr(STDIN_FILENO, 0, &saved_termios);
@@ -97,7 +98,7 @@ int destroy_window(void) {
9798
return 0;
9899
}
99100

100-
int init_window(void) {
101+
static int init_window(void) {
101102
setlocale(LC_ALL, NULL);
102103

103104
tui_started = true;
@@ -151,7 +152,7 @@ void tui_terminate(int sig) {
151152
}
152153
}
153154

154-
void resize_handler(int sig) {
155+
static void resize_handler(int sig) {
155156
redraw_screen();
156157
}
157158

src/tui_screen_enter_dfu.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
#include <palerain.h>
2929
#include <tui.h>
3030

31-
int tui_enter_dfu_nav_selection = 1;
32-
bool tui_device_is_entering_dfu = false;
33-
int tui_enter_dfu_status = 0;
31+
static int tui_enter_dfu_nav_selection = 1;
32+
static bool tui_device_is_entering_dfu = false;
33+
static int tui_enter_dfu_status = 0;
3434

3535
enum {
3636
DEVICE_TYPE_IPHONE_SE,
@@ -41,7 +41,7 @@ enum {
4141
DEVICE_TYPE_IPOD_TOUCH
4242
} device_type;
4343

44-
int tui_product_type_to_device_type(char *product_type) {
44+
static int tui_product_type_to_device_type(char *product_type) {
4545
if (strcmp(product_type, "iPhone8,1") == 0 || strcmp(product_type, "iPhone8,2") == 0) {
4646
return DEVICE_TYPE_IPHONE_6S;
4747
}
@@ -68,11 +68,11 @@ int tui_product_type_to_device_type(char *product_type) {
6868
return DEVICE_TYPE_IPHONE_SE;
6969
}
7070

71-
int tui_enter_dfu_device_type = DEVICE_TYPE_IPHONE_SE;
71+
static int tui_enter_dfu_device_type = DEVICE_TYPE_IPHONE_SE;
7272

73-
int tui_enter_dfu_loading_progress = 1;
73+
static int tui_enter_dfu_loading_progress = 1;
7474

75-
void tui_screen_enter_dfu_nav(void) {
75+
static void tui_screen_enter_dfu_nav(void) {
7676
MOVETOT(80 - 22, 23);
7777
printf("%s[ Cancel ]" COLOR(FG_WHITE, BG_BLACK) " %s[ %s ]" COLOR(FG_WHITE, BG_BLACK),
7878
tui_device_is_entering_dfu || tui_enter_dfu_status == 1 ? (supports_bright_colors ? COLOR(FG_BRIGHT_BLACK, BG_BLACK) : COLOR(FG_BLUE, BG_BLACK)) : tui_enter_dfu_nav_selection == 0 ? "\033[30;107m" : (
@@ -343,9 +343,9 @@ void tui_screen_enter_dfu_redraw(void) {
343343
}
344344

345345
// TODO: IMPLEMENT REAL ENTER RECOVERY
346-
int dfu_time = 0;
346+
static int dfu_time = 0;
347347

348-
tui_screen_t tui_enter_dfu(void) {
348+
static tui_screen_t tui_enter_dfu(void) {
349349
if (tui_connected_devices && !tui_connected_devices->next) {
350350
if (tui_connected_devices->mode == TUI_DEVICE_MODE_NORMAL) {
351351
tui_enter_dfu_status = 0;
@@ -391,7 +391,7 @@ tui_screen_t tui_enter_dfu(void) {
391391
return JAILBREAK_SCREEN;
392392
}
393393

394-
int tui_enter_dfu_nav_mouse_select = -1;
394+
static int tui_enter_dfu_nav_mouse_select = -1;
395395

396396
tui_screen_t tui_screen_enter_dfu(void) {
397397
if (tui_connected_devices && !tui_connected_devices->next) {

0 commit comments

Comments
 (0)