Fix build with -Wmissing-declarations.

While there, add -Wmissing-prototypes and -Wmissing-declarations
to shared.mk in order to catch similar errors in the future.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
This commit is contained in:
Piotr Sikora 2016-03-18 19:18:59 -07:00
parent f453b1bf36
commit 501cb86172
10 changed files with 185 additions and 180 deletions

View File

@ -236,7 +236,7 @@ class StartPosQueue {
// Returns the minimum possible copy length that can improve the cost of any
// future position.
size_t ComputeMinimumCopyLength(const StartPosQueue& queue,
static size_t ComputeMinimumCopyLength(const StartPosQueue& queue,
const ZopfliNode* nodes,
const ZopfliCostModel& model,
const size_t num_bytes,
@ -272,7 +272,7 @@ size_t ComputeMinimumCopyLength(const StartPosQueue& queue,
// starting_dist_cach[0..3].
// REQUIRES: nodes[pos].cost < kInfinity
// REQUIRES: nodes[0..pos] satisfies that "ZopfliNode array invariant".
void ComputeDistanceCache(const size_t block_start,
static void ComputeDistanceCache(const size_t block_start,
const size_t pos,
const size_t max_backward,
const int* starting_dist_cache,
@ -302,7 +302,7 @@ void ComputeDistanceCache(const size_t block_start,
}
}
void UpdateNodes(const size_t num_bytes,
static void UpdateNodes(const size_t num_bytes,
const size_t block_start,
const size_t pos,
const uint8_t* ringbuffer,
@ -408,7 +408,7 @@ void UpdateNodes(const size_t num_bytes,
}
}
void ComputeShortestPathFromNodes(size_t num_bytes,
static void ComputeShortestPathFromNodes(size_t num_bytes,
const ZopfliNode* nodes,
std::vector<uint32_t>* path) {
std::vector<uint32_t> backwards(num_bytes / 2 + 1);
@ -467,7 +467,7 @@ void ZopfliCreateCommands(const size_t num_bytes,
*last_insert_len += num_bytes - pos;
}
void ZopfliIterate(size_t num_bytes,
static void ZopfliIterate(size_t num_bytes,
size_t position,
const uint8_t* ringbuffer,
size_t ringbuffer_mask,

View File

@ -229,7 +229,7 @@ size_t FindBlocks(const DataType* data, const size_t length,
return num_blocks;
}
size_t RemapBlockIds(uint8_t* block_ids, const size_t length,
static size_t RemapBlockIds(uint8_t* block_ids, const size_t length,
uint16_t* new_id, const size_t num_histograms) {
static const uint16_t kInvalidId = 256;
for (size_t i = 0; i < num_histograms; ++i) {

View File

@ -165,7 +165,7 @@ void StoreHuffmanTreeOfHuffmanTreeToBitMask(
}
}
void StoreHuffmanTreeToBitMask(
static void StoreHuffmanTreeToBitMask(
const size_t huffman_tree_size,
const uint8_t* huffman_tree,
const uint8_t* huffman_tree_extra_bits,
@ -189,7 +189,7 @@ void StoreHuffmanTreeToBitMask(
}
}
void StoreSimpleHuffmanTree(const uint8_t* depths,
static void StoreSimpleHuffmanTree(const uint8_t* depths,
size_t symbols[4],
size_t num_symbols,
size_t max_bits,
@ -494,7 +494,7 @@ void BuildAndStoreHuffmanTreeFast(const uint32_t *histogram,
}
}
size_t IndexOf(const uint8_t* v, size_t v_size, uint8_t value) {
static size_t IndexOf(const uint8_t* v, size_t v_size, uint8_t value) {
size_t i = 0;
for (; i < v_size; ++i) {
if (v[i] == value) return i;
@ -502,7 +502,7 @@ size_t IndexOf(const uint8_t* v, size_t v_size, uint8_t value) {
return i;
}
void MoveToFront(uint8_t* v, size_t index) {
static void MoveToFront(uint8_t* v, size_t index) {
uint8_t value = v[index];
for (size_t i = index; i != 0; --i) {
v[i] = v[i - 1];
@ -510,7 +510,7 @@ void MoveToFront(uint8_t* v, size_t index) {
v[0] = value;
}
void MoveToFrontTransform(const uint32_t* __restrict v_in,
static void MoveToFrontTransform(const uint32_t* __restrict v_in,
const size_t v_size,
uint32_t* v_out) {
if (v_size == 0) {
@ -537,7 +537,7 @@ void MoveToFrontTransform(const uint32_t* __restrict v_in,
// *max_length_prefix. Will not create prefix codes bigger than the initial
// value of *max_run_length_prefix. The prefix code of run length L is simply
// Log2Floor(L) and the number of extra bits is the same as the prefix code.
void RunLengthCodeZeros(const size_t in_size,
static void RunLengthCodeZeros(const size_t in_size,
uint32_t* __restrict v,
size_t* __restrict out_size,
uint32_t* __restrict max_run_length_prefix) {
@ -646,7 +646,7 @@ void StoreBlockSwitch(const BlockSplitCode& code,
storage_ix, storage);
}
void BuildAndStoreBlockSplitCode(const std::vector<uint8_t>& types,
static void BuildAndStoreBlockSplitCode(const std::vector<uint8_t>& types,
const std::vector<uint32_t>& lengths,
const size_t num_types,
HuffmanTree* tree,
@ -823,7 +823,7 @@ class BlockEncoder {
std::vector<uint16_t> bits_;
};
void JumpToByteBoundary(size_t* storage_ix, uint8_t* storage) {
static void JumpToByteBoundary(size_t* storage_ix, uint8_t* storage) {
*storage_ix = (*storage_ix + 7u) & ~7u;
storage[*storage_ix >> 3] = 0;
}
@ -947,7 +947,7 @@ void StoreMetaBlock(const uint8_t* input,
}
}
void BuildHistograms(const uint8_t* input,
static void BuildHistograms(const uint8_t* input,
size_t start_pos,
size_t mask,
const brotli::Command *commands,
@ -970,7 +970,7 @@ void BuildHistograms(const uint8_t* input,
}
}
void StoreDataWithHuffmanCodes(const uint8_t* input,
static void StoreDataWithHuffmanCodes(const uint8_t* input,
size_t start_pos,
size_t mask,
const brotli::Command *commands,

View File

@ -58,7 +58,7 @@ static inline int IsMatch(const uint8_t* p1, const uint8_t* p2) {
// we can only approximate the statistics of the actual literal stream.
// Moreover, for long inputs we build a histogram from a sample of the input
// and thus have to assign a non-zero depth for each literal.
void BuildAndStoreLiteralPrefixCode(const uint8_t* input,
static void BuildAndStoreLiteralPrefixCode(const uint8_t* input,
const size_t input_size,
uint8_t depths[256],
uint16_t bits[256],
@ -102,9 +102,11 @@ void BuildAndStoreLiteralPrefixCode(const uint8_t* input,
// Builds a command and distance prefix code (each 64 symbols) into "depth" and
// "bits" based on "histogram" and stores it into the bit stream.
void BuildAndStoreCommandPrefixCode(const uint32_t histogram[128],
uint8_t depth[128], uint16_t bits[128],
size_t* storage_ix, uint8_t* storage) {
static void BuildAndStoreCommandPrefixCode(const uint32_t histogram[128],
uint8_t depth[128],
uint16_t bits[128],
size_t* storage_ix,
uint8_t* storage) {
// Tree size for building a tree over 64 symbols is 2 * 64 + 1.
static const size_t kTreeSize = 129;
HuffmanTree tree[kTreeSize];
@ -315,7 +317,7 @@ static void StoreMetaBlockHeader(
WriteBits(1, is_uncompressed, storage_ix, storage);
}
void UpdateBits(size_t n_bits,
static void UpdateBits(size_t n_bits,
uint32_t bits,
size_t pos,
uint8_t *array) {
@ -336,7 +338,7 @@ void UpdateBits(size_t n_bits,
}
}
void RewindBitPosition(const size_t new_storage_ix,
static void RewindBitPosition(const size_t new_storage_ix,
size_t* storage_ix, uint8_t* storage) {
const size_t bitpos = new_storage_ix & 7;
const size_t mask = (1u << bitpos) - 1;
@ -344,7 +346,8 @@ void RewindBitPosition(const size_t new_storage_ix,
*storage_ix = new_storage_ix;
}
bool ShouldMergeBlock(const uint8_t* data, size_t len, const uint8_t* depths) {
static bool ShouldMergeBlock(const uint8_t* data, size_t len,
const uint8_t* depths) {
size_t histo[256] = { 0 };
static const size_t kSampleRate = 43;
for (size_t i = 0; i < len; i += kSampleRate) {
@ -377,7 +380,7 @@ inline bool ShouldUseUncompressedMode(const uint8_t* metablock_start,
return sum > static_cast<uint32_t>((1 << 15) * kMinEntropy);
}
void EmitUncompressedMetaBlock(const uint8_t* begin, const uint8_t* end,
static void EmitUncompressedMetaBlock(const uint8_t* begin, const uint8_t* end,
const size_t storage_ix_start,
size_t* storage_ix, uint8_t* storage) {
const size_t len = static_cast<size_t>(end - begin);

View File

@ -220,8 +220,8 @@ static void StoreMetaBlockHeader(
WriteBits(1, is_uncompressed, storage_ix, storage);
}
void CreateCommands(const uint8_t* input, size_t block_size, size_t input_size,
const uint8_t* base_ip,
static void CreateCommands(const uint8_t* input, size_t block_size,
size_t input_size, const uint8_t* base_ip,
int* table, size_t table_size,
uint8_t** literals, uint32_t** commands) {
// "ip" is the input pointer.
@ -400,7 +400,7 @@ emit_remainder:
}
}
void StoreCommands(const uint8_t* literals, const size_t num_literals,
static void StoreCommands(const uint8_t* literals, const size_t num_literals,
const uint32_t* commands, const size_t num_commands,
size_t* storage_ix, uint8_t* storage) {
uint8_t lit_depths[256] = { 0 };
@ -458,7 +458,7 @@ void StoreCommands(const uint8_t* literals, const size_t num_literals,
}
}
bool ShouldCompress(const uint8_t* input, size_t input_size,
static bool ShouldCompress(const uint8_t* input, size_t input_size,
size_t num_literals) {
static const double kAcceptableLossForUncompressibleSpeedup = 0.02;
static const double kMaxRatioOfLiterals =

View File

@ -42,7 +42,7 @@ static const size_t kMaxNumDelayedSymbols = 0x2fff;
#define COPY_ARRAY(dst, src) memcpy(dst, src, sizeof(src));
void RecomputeDistancePrefixes(Command* cmds,
static void RecomputeDistancePrefixes(Command* cmds,
size_t num_commands,
uint32_t num_direct_distance_codes,
uint32_t distance_postfix_bits) {
@ -63,7 +63,7 @@ void RecomputeDistancePrefixes(Command* cmds,
/* Wraps 64-bit input position to 32-bit ringbuffer position preserving
"not-a-first-lap" feature. */
uint32_t WrapPosition(uint64_t position) {
static uint32_t WrapPosition(uint64_t position) {
uint32_t result = static_cast<uint32_t>(position);
if (position > (1u << 30)) {
result = (result & ((1u << 30) - 1)) | (1u << 30);
@ -80,11 +80,11 @@ uint8_t* BrotliCompressor::GetBrotliStorage(size_t size) {
return storage_;
}
size_t MaxHashTableSize(int quality) {
static size_t MaxHashTableSize(int quality) {
return quality == 0 ? 1 << 15 : 1 << 17;
}
size_t HashTableSize(size_t max_table_size, size_t input_size) {
static size_t HashTableSize(size_t max_table_size, size_t input_size) {
size_t htsize = 256;
while (htsize < max_table_size && htsize < input_size) {
htsize <<= 1;
@ -118,7 +118,8 @@ int* BrotliCompressor::GetHashTable(int quality,
return table;
}
void EncodeWindowBits(int lgwin, uint8_t* last_byte, uint8_t* last_byte_bits) {
static void EncodeWindowBits(int lgwin, uint8_t* last_byte,
uint8_t* last_byte_bits) {
if (lgwin == 16) {
*last_byte = 0;
*last_byte_bits = 1;
@ -135,7 +136,7 @@ void EncodeWindowBits(int lgwin, uint8_t* last_byte, uint8_t* last_byte_bits) {
}
// Initializes the command and distance prefix codes for the first block.
void InitCommandPrefixCodes(uint8_t cmd_depths[128],
static void InitCommandPrefixCodes(uint8_t cmd_depths[128],
uint16_t cmd_bits[128],
uint8_t cmd_code[512],
size_t* cmd_code_numbits) {
@ -187,7 +188,7 @@ void InitCommandPrefixCodes(uint8_t cmd_depths[128],
// encoded with the remaining 6 bits of the following byte, and
// BitsEntropy will assume that symbol to be stored alone using Huffman
// coding.
void ChooseContextMap(int quality,
static void ChooseContextMap(int quality,
uint32_t* bigram_histo,
size_t* num_literal_contexts,
const uint32_t** literal_context_map) {
@ -248,7 +249,8 @@ void ChooseContextMap(int quality,
}
}
void DecideOverLiteralContextModeling(const uint8_t* input,
static void DecideOverLiteralContextModeling(
const uint8_t* input,
size_t start_pos,
size_t length,
size_t mask,
@ -279,7 +281,7 @@ void DecideOverLiteralContextModeling(const uint8_t* input,
literal_context_map);
}
bool ShouldCompress(const uint8_t* data,
static bool ShouldCompress(const uint8_t* data,
const size_t mask,
const uint64_t last_flush_pos,
const size_t bytes,
@ -306,7 +308,7 @@ bool ShouldCompress(const uint8_t* data,
return true;
}
void WriteMetaBlockInternal(const uint8_t* data,
static void WriteMetaBlockInternal(const uint8_t* data,
const size_t mask,
const uint64_t last_flush_pos,
const size_t bytes,
@ -771,7 +773,7 @@ bool BrotliCompressor::FinishStream(
return WriteMetaBlock(0, NULL, true, encoded_size, encoded_buffer);
}
int BrotliCompressBufferQuality10(int lgwin,
static int BrotliCompressBufferQuality10(int lgwin,
size_t input_size,
const uint8_t* input_buffer,
size_t* encoded_size,
@ -972,12 +974,12 @@ int BrotliCompressBuffer(BrotliParams params,
return 1;
}
bool BrotliInIsFinished(BrotliIn* r) {
static bool BrotliInIsFinished(BrotliIn* r) {
size_t read_bytes;
return r->Read(0, &read_bytes) == NULL;
}
const uint8_t* BrotliInReadAndCheckEnd(const size_t block_size,
static const uint8_t* BrotliInReadAndCheckEnd(const size_t block_size,
BrotliIn* r,
size_t* bytes_read,
bool* is_last) {
@ -989,7 +991,7 @@ const uint8_t* BrotliInReadAndCheckEnd(const size_t block_size,
return data;
}
bool CopyOneBlockToRingBuffer(BrotliIn* r,
static bool CopyOneBlockToRingBuffer(BrotliIn* r,
BrotliCompressor* compressor,
size_t* bytes_read,
bool* is_last) {

View File

@ -132,7 +132,7 @@ void CreateHuffmanTree(const uint32_t *data,
}
}
void Reverse(uint8_t* v, size_t start, size_t end) {
static void Reverse(uint8_t* v, size_t start, size_t end) {
--end;
while (start < end) {
uint8_t tmp = v[start];
@ -143,7 +143,7 @@ void Reverse(uint8_t* v, size_t start, size_t end) {
}
}
void WriteHuffmanTreeRepetitions(
static void WriteHuffmanTreeRepetitions(
const uint8_t previous_value,
const uint8_t value,
size_t repetitions,
@ -187,7 +187,7 @@ void WriteHuffmanTreeRepetitions(
}
}
void WriteHuffmanTreeRepetitionsZeros(
static void WriteHuffmanTreeRepetitionsZeros(
size_t repetitions,
size_t* tree_size,
uint8_t* tree,

View File

@ -53,7 +53,7 @@ static size_t DecideMultiByteStatsLevel(size_t pos, size_t len, size_t mask,
return max_utf8;
}
void EstimateBitCostsForLiteralsUTF8(size_t pos, size_t len, size_t mask,
static void EstimateBitCostsForLiteralsUTF8(size_t pos, size_t len, size_t mask,
const uint8_t *data, float *cost) {
// max_utf8 is 0 (normal ascii single byte modeling),

View File

@ -9,5 +9,5 @@ ifeq ($(OS), Darwin)
CPPFLAGS += -DOS_MACOSX
endif
CFLAGS += $(COMMON_FLAGS)
CXXFLAGS += $(COMMON_FLAGS)
CFLAGS += $(COMMON_FLAGS) -Wmissing-prototypes
CXXFLAGS += $(COMMON_FLAGS) -Wmissing-declarations

View File

@ -167,7 +167,7 @@ static FILE *OpenOutputFile(const char *output_path, const int force) {
return fdopen(fd, "wb");
}
int64_t FileSize(char *path) {
static int64_t FileSize(char *path) {
FILE *f = fopen(path, "rb");
if (f == NULL) {
return -1;
@ -185,7 +185,7 @@ int64_t FileSize(char *path) {
static const size_t kFileBufferSize = 65536;
void Decompresss(FILE* fin, FILE* fout) {
static void Decompresss(FILE* fin, FILE* fout) {
uint8_t* input = new uint8_t[kFileBufferSize];
uint8_t* output = new uint8_t[kFileBufferSize];
size_t total_out;