Skip to content

Commit c6bf3b5

Browse files
committed
fix litespeed SAPI build warnings.
helpers only called on linux anyways, proper C calls prototypes.
1 parent 11b612a commit c6bf3b5

File tree

2 files changed

+55
-33
lines changed

2 files changed

+55
-33
lines changed

sapi/litespeed/lsapi_main.c

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,9 @@ static void log_message (const char *fmt, ...)
537537
#define DEBUG_MESSAGE(fmt, ...)
538538
#endif
539539

540-
static int lsapi_activate_user_ini();
540+
static int lsapi_activate_user_ini(void);
541541

542-
static int sapi_lsapi_activate()
542+
static int sapi_lsapi_activate(void)
543543
{
544544
char *path, *server_name;
545545
size_t path_len, server_name_len;
@@ -677,10 +677,9 @@ static int do_clean_shutdown = 1;
677677
static int clean_onexit = 1;
678678

679679

680-
static void lsapi_clean_shutdown()
680+
static void lsapi_clean_shutdown(void)
681681
{
682682
struct sigaction act;
683-
int sa_rc;
684683
struct itimerval tmv;
685684
#if PHP_MAJOR_VERSION >= 7
686685
zend_string * key;
@@ -689,15 +688,31 @@ static void lsapi_clean_shutdown()
689688
sigemptyset(&act.sa_mask);
690689
act.sa_flags = 0;
691690
act.sa_handler = lsapi_sigsegv;
692-
sa_rc = sigaction(SIGINT, &act, NULL);
693-
sa_rc = sigaction(SIGQUIT, &act, NULL);
694-
sa_rc = sigaction(SIGILL, &act, NULL);
695-
sa_rc = sigaction(SIGABRT, &act, NULL);
696-
sa_rc = sigaction(SIGBUS, &act, NULL);
697-
sa_rc = sigaction(SIGSEGV, &act, NULL);
698-
sa_rc = sigaction(SIGTERM, &act, NULL);
699-
700-
sa_rc = sigaction(SIGPROF, &act, NULL);
691+
if (sigaction(SIGINT, &act, NULL) < 0) {
692+
return;
693+
}
694+
if (sigaction(SIGQUIT, &act, NULL) < 0) {
695+
return;
696+
}
697+
if (sigaction(SIGILL, &act, NULL) < 0) {
698+
return;
699+
}
700+
if (sigaction(SIGABRT, &act, NULL) < 0) {
701+
return;
702+
}
703+
if (sigaction(SIGBUS, &act, NULL) < 0) {
704+
return;
705+
}
706+
if (sigaction(SIGSEGV, &act, NULL) < 0) {
707+
return;
708+
}
709+
if (sigaction(SIGTERM, &act, NULL) < 0) {
710+
return;
711+
}
712+
713+
if (sigaction(SIGPROF, &act, NULL) < 0) {
714+
return;
715+
}
701716
memset(&tmv, 0, sizeof(struct itimerval));
702717
tmv.it_value.tv_sec = 0;
703718
tmv.it_value.tv_usec = 100000;
@@ -738,11 +753,9 @@ static void lsapi_atexit(void)
738753
}
739754
}
740755

741-
742756
static int lsapi_module_main(int show_source)
743757
{
744758
struct sigaction act;
745-
int sa_rc;
746759
if (php_request_startup() == FAILURE ) {
747760
return -1;
748761
}
@@ -751,13 +764,28 @@ static int lsapi_module_main(int show_source)
751764
sigemptyset(&act.sa_mask);
752765
act.sa_flags = SA_NODEFER;
753766
act.sa_handler = lsapi_sigterm;
754-
sa_rc = sigaction( SIGINT, &act, NULL);
755-
sa_rc = sigaction( SIGQUIT, &act, NULL);
756-
sa_rc = sigaction( SIGILL, &act, NULL);
757-
sa_rc = sigaction( SIGABRT, &act, NULL);
758-
sa_rc = sigaction( SIGBUS, &act, NULL);
759-
sa_rc = sigaction( SIGSEGV, &act, NULL);
760-
sa_rc = sigaction( SIGTERM, &act, NULL);
767+
if (sigaction( SIGINT, &act, NULL) < 0) {
768+
return -1;
769+
}
770+
771+
if (sigaction( SIGQUIT, &act, NULL) < 0) {
772+
return -1;
773+
}
774+
if (sigaction( SIGILL, &act, NULL) < 0) {
775+
return -1;
776+
}
777+
if (sigaction( SIGABRT, &act, NULL) < 0) {
778+
return -1;
779+
}
780+
if (sigaction( SIGBUS, &act, NULL) < 0) {
781+
return -1;
782+
}
783+
if (sigaction( SIGSEGV, &act, NULL) < 0) {
784+
return -1;
785+
}
786+
if (sigaction( SIGTERM, &act, NULL) < 0) {
787+
return -1;
788+
}
761789

762790
clean_onexit = 0;
763791
}

sapi/litespeed/lsapilib.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,7 @@ static int LSAPI_perror_r( LSAPI_Request * pReq, const char * pErr1, const char
922922
}
923923

924924

925+
#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__gnu_linux__)
925926
static int lsapi_lve_error( LSAPI_Request * pReq )
926927
{
927928
static const char * headers[] =
@@ -945,10 +946,8 @@ static int lsapi_lve_error( LSAPI_Request * pReq )
945946
return 0;
946947
}
947948

948-
949949
static int lsapi_enterLVE( LSAPI_Request * pReq, uid_t uid )
950950
{
951-
#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__gnu_linux__)
952951
if ( s_lve && uid ) //root user should not do that
953952
{
954953
uint32_t cookie;
@@ -962,16 +961,13 @@ static int lsapi_enterLVE( LSAPI_Request * pReq, uid_t uid )
962961
return -1;
963962
}
964963
}
965-
#endif
966964

967965
return 0;
968966
}
969967

970-
971968
static int lsapi_jailLVE( LSAPI_Request * pReq, uid_t uid, struct passwd * pw )
972969
{
973970
int ret = 0;
974-
#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__gnu_linux__)
975971
char error_msg[1024] = "";
976972
ret = (*fp_lve_jail)( pw, error_msg );
977973
if ( ret < 0 )
@@ -981,12 +977,10 @@ static int lsapi_jailLVE( LSAPI_Request * pReq, uid_t uid, struct passwd * pw )
981977
LSAPI_perror_r( pReq, "LSAPI: jail() failure.", NULL );
982978
return -1;
983979
}
984-
#endif
985980
return ret;
986981
}
987982

988983

989-
#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__gnu_linux__)
990984
static int lsapi_initLVE(void)
991985
{
992986
const char * pEnv;
@@ -1368,7 +1362,7 @@ static inline int lsapi_notify_pid( int fd )
13681362

13691363

13701364
static char s_conn_key_packet[16];
1371-
static inline int init_conn_key( int fd )
1365+
static inline __attribute__((unused)) int init_conn_key( int fd )
13721366
{
13731367
struct lsapi_packet_header * pHeader = (struct lsapi_packet_header *)s_conn_key_packet;
13741368
struct timeval tv;
@@ -3160,11 +3154,11 @@ static void lsapi_check_child_status( long tmCur )
31603154
//}
31613155

31623156

3163-
void set_skip_write()
3157+
void set_skip_write(void)
31643158
{ s_skip_write = 1; }
31653159

31663160

3167-
int is_enough_free_mem()
3161+
int is_enough_free_mem(void)
31683162
{
31693163
#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__gnu_linux__)
31703164
//minimum 1GB or 10% available free memory
@@ -3832,7 +3826,7 @@ void LSAPI_No_Check_ppid(void)
38323826
}
38333827

38343828

3835-
int LSAPI_Get_ppid()
3829+
int LSAPI_Get_ppid(void)
38363830
{
38373831
return(s_ppid);
38383832
}

0 commit comments

Comments
 (0)