Skip to content

Commit 8a221e2

Browse files
committed
fix litespeed SAPI build warnings.
- helpers only called on linux anyway. - proper C calls prototypes. Closes GH-10068.
1 parent b77edf8 commit 8a221e2

File tree

3 files changed

+28
-62
lines changed

3 files changed

+28
-62
lines changed

sapi/litespeed/lsapi_main.c

Lines changed: 20 additions & 24 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,14 @@ 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+
(void)sigaction(SIGINT, &act, NULL);
692+
(void)sigaction(SIGQUIT, &act, NULL);
693+
(void)sigaction(SIGILL, &act, NULL);
694+
(void)sigaction(SIGABRT, &act, NULL);
695+
(void)sigaction(SIGBUS, &act, NULL);
696+
(void)sigaction(SIGSEGV, &act, NULL);
697+
(void)sigaction(SIGTERM, &act, NULL);
698+
(void)sigaction(SIGPROF, &act, NULL);
701699
memset(&tmv, 0, sizeof(struct itimerval));
702700
tmv.it_value.tv_sec = 0;
703701
tmv.it_value.tv_usec = 100000;
@@ -738,11 +736,9 @@ static void lsapi_atexit(void)
738736
}
739737
}
740738

741-
742739
static int lsapi_module_main(int show_source)
743740
{
744741
struct sigaction act;
745-
int sa_rc;
746742
if (php_request_startup() == FAILURE ) {
747743
return -1;
748744
}
@@ -751,13 +747,13 @@ static int lsapi_module_main(int show_source)
751747
sigemptyset(&act.sa_mask);
752748
act.sa_flags = SA_NODEFER;
753749
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);
750+
(void)sigaction( SIGINT, &act, NULL);
751+
(void)sigaction( SIGQUIT, &act, NULL);
752+
(void)sigaction( SIGILL, &act, NULL);
753+
(void)sigaction( SIGABRT, &act, NULL);
754+
(void)sigaction( SIGBUS, &act, NULL);
755+
(void)sigaction( SIGSEGV, &act, NULL);
756+
(void)sigaction( SIGTERM, &act, NULL);
761757

762758
clean_onexit = 0;
763759
}
@@ -834,7 +830,7 @@ static void user_config_cache_entry_dtor(zval *el)
834830
free(entry);
835831
}
836832

837-
static void user_config_cache_init()
833+
static void user_config_cache_init(void)
838834
{
839835
zend_hash_init(&user_config_cache, 0, NULL, user_config_cache_entry_dtor, 1);
840836
}
@@ -1101,7 +1097,7 @@ static int lsapi_activate_user_ini( void )
11011097
}
11021098

11031099

1104-
static void override_ini()
1100+
static void override_ini(void)
11051101
{
11061102

11071103
LSAPI_ForeachSpecialEnv( alter_ini, NULL );

sapi/litespeed/lsapilib.c

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ static int LSAPI_perror_r( LSAPI_Request * pReq, const char * pErr1, const char
921921
}
922922

923923

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

947-
948948
static int lsapi_enterLVE( LSAPI_Request * pReq, uid_t uid )
949949
{
950-
#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__gnu_linux__)
951950
if ( s_lve && uid ) //root user should not do that
952951
{
953952
uint32_t cookie;
@@ -961,16 +960,13 @@ static int lsapi_enterLVE( LSAPI_Request * pReq, uid_t uid )
961960
return -1;
962961
}
963962
}
964-
#endif
965963

966964
return 0;
967965
}
968966

969-
970967
static int lsapi_jailLVE( LSAPI_Request * pReq, uid_t uid, struct passwd * pw )
971968
{
972969
int ret = 0;
973-
#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__gnu_linux__)
974970
char error_msg[1024] = "";
975971
ret = (*fp_lve_jail)( pw, error_msg );
976972
if ( ret < 0 )
@@ -980,12 +976,10 @@ static int lsapi_jailLVE( LSAPI_Request * pReq, uid_t uid, struct passwd * pw )
980976
LSAPI_perror_r( pReq, "LSAPI: jail() failure.", NULL );
981977
return -1;
982978
}
983-
#endif
984979
return ret;
985980
}
986981

987982

988-
#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__gnu_linux__)
989983
static int lsapi_initLVE(void)
990984
{
991985
const char * pEnv;
@@ -1365,30 +1359,6 @@ static inline int lsapi_notify_pid( int fd )
13651359
return 0;
13661360
}
13671361

1368-
1369-
static char s_conn_key_packet[16];
1370-
static inline int init_conn_key( int fd )
1371-
{
1372-
struct lsapi_packet_header * pHeader = (struct lsapi_packet_header *)s_conn_key_packet;
1373-
struct timeval tv;
1374-
int i;
1375-
gettimeofday( &tv, NULL );
1376-
srand( (tv.tv_sec % 0x1000 + tv.tv_usec) ^ rand() );
1377-
for( i = 8; i < 16; ++i )
1378-
{
1379-
s_conn_key_packet[i]=(int) (256.0*rand()/(RAND_MAX+1.0));
1380-
}
1381-
lsapi_buildPacketHeader( pHeader, LSAPI_REQ_RECEIVED,
1382-
8 + LSAPI_PACKET_HEADER_LEN );
1383-
if ( write( fd, s_conn_key_packet, LSAPI_PACKET_HEADER_LEN+8 )
1384-
< LSAPI_PACKET_HEADER_LEN+8 )
1385-
return -1;
1386-
return 0;
1387-
1388-
1389-
}
1390-
1391-
13921362
static int readReq( LSAPI_Request * pReq )
13931363
{
13941364
int len;
@@ -3159,11 +3129,11 @@ static void lsapi_check_child_status( long tmCur )
31593129
//}
31603130

31613131

3162-
void set_skip_write()
3132+
void set_skip_write(void)
31633133
{ s_skip_write = 1; }
31643134

31653135

3166-
int is_enough_free_mem()
3136+
int is_enough_free_mem(void)
31673137
{
31683138
#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__gnu_linux__)
31693139
//minimum 1GB or 10% available free memory
@@ -3831,7 +3801,7 @@ void LSAPI_No_Check_ppid(void)
38313801
}
38323802

38333803

3834-
int LSAPI_Get_ppid()
3804+
int LSAPI_Get_ppid(void)
38353805
{
38363806
return(s_ppid);
38373807
}

sapi/litespeed/lscriu.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9595
static int s_initial_start_reqs = 0;
9696
static int s_requests_count = 0;
9797
static int s_restored = 0;
98-
static int (*s_lscapi_dump_me)() = NULL;
99-
static int (*s_lscapi_prepare_me)() = NULL;
98+
static int (*s_lscapi_dump_me)(void) = NULL;
99+
static int (*s_lscapi_prepare_me)(void) = NULL;
100100
static int s_native = 0;
101101
static int s_tried_checkpoint = 0;
102102
static int s_criu_debug = 0;
@@ -118,7 +118,7 @@ typedef void (*sighandler_t)(int);
118118

119119
void lsapi_perror( const char * pMessage, int err_no );
120120
void LSAPI_reset_server_state( void );
121-
int LSAPI_Get_ppid();
121+
int LSAPI_Get_ppid(void);
122122

123123
#ifdef LSAPILIB_DEBUG_CRIU
124124
#define lscriu_dbg(...) \
@@ -541,7 +541,7 @@ static void LSCRIU_try_checkpoint(int *forked_pid)
541541
}
542542

543543

544-
static int init_native_env()
544+
static int init_native_env(void)
545545
{
546546
char *pchFd;
547547
pchFd = getenv("LSAPI_CRIU_SYNC_FD");

0 commit comments

Comments
 (0)