Skip to content

Commit

Permalink
add missing static's + add a test script
Browse files Browse the repository at this point in the history
  • Loading branch information
erankor committed Feb 28, 2017
1 parent b399e28 commit 29db655
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 21 deletions.
2 changes: 1 addition & 1 deletion ngx_http_vod_conf.c
Expand Up @@ -421,7 +421,7 @@ ngx_http_vod_set_time_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_OK;
}

char *
static char *
ngx_http_vod_set_signed_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
char *p = conf;
Expand Down
2 changes: 1 addition & 1 deletion ngx_http_vod_hds.c
Expand Up @@ -275,7 +275,7 @@ ngx_http_vod_hds_parse_uri_file_name(
return NGX_OK;
}

ngx_int_t
static ngx_int_t
ngx_http_vod_hds_parse_drm_info(
ngx_http_vod_submodule_context_t* submodule_context,
ngx_str_t* drm_info,
Expand Down
4 changes: 2 additions & 2 deletions ngx_http_vod_hls.c
Expand Up @@ -417,7 +417,7 @@ static const ngx_http_vod_request_t hls_vtt_segment_request = {
NULL,
};

void
static void
ngx_http_vod_hls_create_loc_conf(
ngx_conf_t *cf,
ngx_http_vod_hls_loc_conf_t *conf)
Expand Down Expand Up @@ -571,7 +571,7 @@ ngx_http_vod_hls_parse_uri_file_name(
return NGX_OK;
}

ngx_int_t
static ngx_int_t
ngx_http_vod_hls_parse_drm_info(
ngx_http_vod_submodule_context_t* submodule_context,
ngx_str_t* drm_info,
Expand Down
9 changes: 5 additions & 4 deletions ngx_http_vod_mss.c
Expand Up @@ -240,7 +240,8 @@ static const ngx_http_vod_request_t mss_ttml_request = {
ngx_http_vod_mss_handle_ttml_fragment,
NULL,
};
void

static void
ngx_http_vod_mss_create_loc_conf(
ngx_conf_t *cf,
ngx_http_vod_mss_loc_conf_t *conf)
Expand All @@ -260,7 +261,7 @@ ngx_http_vod_mss_merge_loc_conf(
return NGX_CONF_OK;
}

int
static int
ngx_http_vod_mss_get_file_path_components(ngx_str_t* uri)
{
u_char* end_pos = uri->data + uri->len;
Expand All @@ -276,7 +277,7 @@ ngx_http_vod_mss_get_file_path_components(ngx_str_t* uri)
}
}

ngx_int_t
static ngx_int_t
ngx_http_vod_mss_parse_uri_file_name(
ngx_http_request_t *r,
ngx_http_vod_loc_conf_t *conf,
Expand Down Expand Up @@ -368,7 +369,7 @@ ngx_http_vod_mss_parse_uri_file_name(
}
}

ngx_int_t
static ngx_int_t
ngx_http_vod_mss_parse_drm_info(
ngx_http_vod_submodule_context_t* submodule_context,
ngx_str_t* drm_info,
Expand Down
2 changes: 1 addition & 1 deletion ngx_http_vod_request_parse.c
Expand Up @@ -136,7 +136,7 @@ ngx_http_vod_extract_uint32_token_reverse(u_char* start_pos, u_char* end_pos, ui
return end_pos;
}

u_char*
static u_char*
ngx_http_vod_extract_track_tokens(u_char* start_pos, u_char* end_pos, uint32_t* result)
{
uint32_t stream_index;
Expand Down
4 changes: 2 additions & 2 deletions ngx_http_vod_thumb.c
Expand Up @@ -140,7 +140,7 @@ static const ngx_http_vod_request_t thumb_request = {
ngx_http_vod_thumb_init_frame_processor,
};

void
static void
ngx_http_vod_thumb_create_loc_conf(
ngx_conf_t *cf,
ngx_http_vod_thumb_loc_conf_t *conf)
Expand Down Expand Up @@ -246,7 +246,7 @@ ngx_http_vod_thumb_parse_uri_file_name(
return NGX_OK;
}

ngx_int_t
static ngx_int_t
ngx_http_vod_thumb_parse_drm_info(
ngx_http_vod_submodule_context_t* submodule_context,
ngx_str_t* drm_info,
Expand Down
4 changes: 2 additions & 2 deletions test/buffer_cache/main.c
Expand Up @@ -46,7 +46,7 @@ ngx_shared_memory_add(ngx_conf_t *cf, ngx_str_t *name, size_t size, void *tag)
}

// buffer cache initialization
ngx_flag_t
static ngx_flag_t
init_buffer_cache(size_t size)
{
ngx_time.sec = 0;
Expand All @@ -62,7 +62,7 @@ init_buffer_cache(size_t size)
return 1;
}

void
static void
free_buffer_cache()
{
free(shm_zone.shm.addr);
Expand Down
76 changes: 76 additions & 0 deletions test/test_static.py
@@ -0,0 +1,76 @@
import commands
import sys
import re
import os

IGNORE_LIST = set([
'vod_array_init_impl',
'vod_array_destroy',
'hls_encryption_methods',
'dash_manifest_formats',
])

if len(sys.argv) < 2:
print 'Usage:\n\t%s <source root> [<object root> [<object use only last folder>]]' % os.path.basename(__file__)
sys.exit(1)

sourceRoot = sys.argv[1]
if len(sys.argv) > 2:
objectRoot = sys.argv[2]
else:
objectRoot = ''

if len(sys.argv) > 3:
useOnlyLastFolder = sys.argv[3].lower() == 'yes'
else:
useOnlyLastFolder = True

funcNames = []
wordsByFile = {}
wordsByHeaderFiles = set([])
for root, dirs, files in os.walk(sourceRoot):
for name in files:
fileExt = os.path.splitext(name)[1]
fullPath = os.path.join(root, name)
if fileExt == '.h':
fileData = file(fullPath, 'rb').read()
wordsByHeaderFiles.update(set(re.findall(r'\b(\w+)\b', fileData)))
continue
if fileExt != '.c':
continue
fileData = file(fullPath, 'rb').read()
wordsByFile[fullPath] = set(re.findall(r'\b(\w+)\b', fileData))
if objectRoot == '':
# detect exports from code
for curLine in fileData.split('\n'):
if re.match('^\w+\(', curLine) and not 'static' in prevLine:
funcName = curLine.split('(')[0]
funcNames.append(funcName)
prevLine = curLine
else:
# get exports from object file
if useOnlyLastFolder:
objectFile = os.path.join(os.path.split(os.path.split(fullPath)[0])[1], os.path.split(fullPath)[1])
else:
objectFile = fullPath[len(sourceRoot):]
if objectFile.startswith('/'):
objectFile = objectFile[1:]
objectFile = os.path.join(objectRoot, os.path.splitext(objectFile)[0] + '.o')
if not os.path.exists(objectFile):
continue
for curLine in commands.getoutput("readelf -Ws %s | grep -vw UND | grep -w GLOBAL | awk '{print $NF}'" % objectFile).split('\n'):
funcName = curLine.strip()
if len(funcName) > 0:
funcNames.append(funcName)

print 'Found %s exports' % len(funcNames)

for funcName in funcNames:
if funcName in IGNORE_LIST:
continue
fileCount = 0
for words in wordsByFile.values():
if funcName in words:
fileCount += 1
if fileCount < 2:
print funcName, funcName in wordsByHeaderFiles
4 changes: 2 additions & 2 deletions vod/cli/vod_cli_main.c
Expand Up @@ -9,7 +9,7 @@
#include "read_cache.h"
#include "muxer.h"

bool_t
static bool_t
write_file(void* context, const u_char* buffer, uint32_t size)
{
int* output_fd = (int*)context;
Expand All @@ -24,7 +24,7 @@ write_file(void* context, const u_char* buffer, uint32_t size)
return TRUE;
}

size_t
static size_t
read_file(void* context, u_char *buf, size_t size, off_t offset)
{
int* input_fd = (int*)context;
Expand Down
4 changes: 2 additions & 2 deletions vod/codec_config.c
Expand Up @@ -428,7 +428,7 @@ codec_config_get_video_codec_name(request_context_t* request_context, media_info
}
}

vod_status_t
static vod_status_t
codec_config_get_mp4a_codec_name(request_context_t* request_context, media_info_t* media_info)
{
u_char* p;
Expand Down Expand Up @@ -784,7 +784,7 @@ parse_avc_sps(const u_char* buffer, int buffer_size)
return parse_avc_rbsp_trailing_bits(&reader);
}

vod_status_t
static vod_status_t
avcc_config_parse_sps(
const u_char* extra_data,
uint32_t extra_data_size)
Expand Down
2 changes: 1 addition & 1 deletion vod/hds/hds_amf0_encoder.c
Expand Up @@ -28,7 +28,7 @@ static const vod_str_t amf0_on_metadata = vod_string("onMetaData");

#define AMF0_FIELD(group, name, type) group +

const int amf0_field_count =
static const int amf0_field_count =
#include "hds_amf0_fields_x.h"
0;

Expand Down
2 changes: 1 addition & 1 deletion vod/hls/buffer_filter.c
Expand Up @@ -427,7 +427,7 @@ buffer_filter_simulated_flush_frame(media_filter_context_t* context, bool_t last
}
}

const media_filter_t buffer_filter = {
static const media_filter_t buffer_filter = {
buffer_filter_start_frame,
buffer_filter_write,
buffer_filter_flush_frame,
Expand Down
2 changes: 1 addition & 1 deletion vod/hls/mpegts_encoder_filter.c
Expand Up @@ -1276,7 +1276,7 @@ mpegts_encoder_simulated_flush_frame(media_filter_context_t* context, bool_t las
}


const media_filter_t mpegts_encoder = {
static const media_filter_t mpegts_encoder = {
mpegts_encoder_start_frame,
mpegts_encoder_write,
mpegts_encoder_flush_frame,
Expand Down
2 changes: 1 addition & 1 deletion vod/thumb/thumb_grabber.c
Expand Up @@ -174,7 +174,7 @@ thumb_grabber_init_encoder(
return VOD_OK;
}

uint32_t
static uint32_t
thumb_grabber_get_max_frame_size(media_track_t* track, uint32_t limit)
{
frame_list_part_t* part;
Expand Down

0 comments on commit 29db655

Please sign in to comment.