libpinyin-2.9.92-1.fc42

List of Findings

Error: CPPCHECK_WARNING (CWE-401): [#def1]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/include/memory_chunk.h:399: error[memleakOnRealloc]: Common realloc mistake: 'm_data_begin' nulled but not freed upon failure
#  397|               return;
#  398|           size_t newsize = size();
#  399|->         m_data_begin = (char *) realloc(m_data_begin, newsize);
#  400|           m_allocated = m_data_begin + newsize;
#  401|       }

Error: COMPILER_WARNING (CWE-1164): [#def2]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/lookup/phonetic_lookup.cpp:21: included_from: Included from here.
libpinyin-2.9.92-build/libpinyin-2.9.92/src/lookup/phonetic_lookup.h:174:13: warning[-Wunused-function]: 'gint pinyin::trellis_value_compare(const trellis_value_t**, const trellis_value_t**)' defined but not used
#  174 | static gint trellis_value_compare(const trellis_value_t ** lhs,
#      |             ^~~~~~~~~~~~~~~~~~~~~
#  172|   }
#  173|   
#  174|-> static gint trellis_value_compare(const trellis_value_t ** lhs,
#  175|                                     const trellis_value_t ** rhs) {
#  176|       /* in descending order */

Error: COMPILER_WARNING (CWE-1164): [#def3]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/lookup/phonetic_lookup.cpp:21: included_from: Included from here.
libpinyin-2.9.92-build/libpinyin-2.9.92/src/lookup/phonetic_lookup.h:174:13: warning[-Wunused-function]: ‘gint pinyin::trellis_value_compare(const trellis_value_t**, const trellis_value_t**)’ defined but not used
#  174 | static gint trellis_value_compare(const trellis_value_t ** lhs,
#      |             ^~~~~~~~~~~~~~~~~~~~~
#  172|   }
#  173|   
#  174|-> static gint trellis_value_compare(const trellis_value_t ** lhs,
#  175|                                     const trellis_value_t ** rhs) {
#  176|       /* in descending order */

Error: COMPILER_WARNING (CWE-563): [#def4]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp: scope_hint: In function 'bool _add_phrase(pinyin_context_t*, guint8, ChewingKeyVector, ucs4_t*, glong, gint)'
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp:541:9: warning[-Wunused-variable]: unused variable 'num'
#  541 |     int num = reduce_tokens(tokens, tokenarray);
#      |         ^~~
#  539|       phrase_index->prepare_tokens(tokens);
#  540|       int retval = phrase_table->search(phrase_length, phrase, tokens);
#  541|->     int num = reduce_tokens(tokens, tokenarray);
#  542|       phrase_index->destroy_tokens(tokens);
#  543|   

Error: COMPILER_WARNING (CWE-563): [#def5]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp: scope_hint: In function 'void _compute_prefixes(pinyin_instance_t*, const char*)'
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp:1415:17: warning[-Wunused-variable]: unused variable 'num'
# 1415 |             int num = reduce_tokens(tokens, tokenarray);
#      |                 ^~~
# 1413|               phrase_index->prepare_tokens(tokens);
# 1414|               int result = context->m_phrase_table->search(i, start, tokens);
# 1415|->             int num = reduce_tokens(tokens, tokenarray);
# 1416|               phrase_index->destroy_tokens(tokens);
# 1417|   

Error: COMPILER_WARNING (CWE-563): [#def6]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp:1883:9: warning[-Wunused-variable]: unused variable 'result'
# 1883 |     int result = search_suggestion_with_matrix
#      |         ^~~~~~
# 1881|       memset(tokens, 0, sizeof(tokens));
# 1882|       phrase_index->prepare_tokens(tokens);
# 1883|->     int result = search_suggestion_with_matrix
# 1884|           (context->m_pinyin_table, &matrix, prefix_len, tokens);
# 1885|       int num = reduce_tokens(tokens, tokenarray, false);

Error: COMPILER_WARNING (CWE-563): [#def7]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp:1885:9: warning[-Wunused-variable]: unused variable 'num'
# 1885 |     int num = reduce_tokens(tokens, tokenarray, false);
#      |         ^~~
# 1883|       int result = search_suggestion_with_matrix
# 1884|           (context->m_pinyin_table, &matrix, prefix_len, tokens);
# 1885|->     int num = reduce_tokens(tokens, tokenarray, false);
# 1886|       phrase_index->destroy_tokens(tokens);
# 1887|   

Error: COMPILER_WARNING (CWE-195): [#def8]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp: scope_hint: In function 'bool _prepend_longer_candidates(pinyin_instance_t*, CandidateVector)'
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp:1890:23: warning[-Wsign-compare]: comparison of integer expressions of different signedness: 'int' and 'guint' {aka 'unsigned int'}
# 1890 |     for (int i = 0; i < tokenarray->len; ++i) {
#      |                     ~~^~~~~~~~~~~~~~~~~
# 1888|       phrase_token_t longer_token = null_token;
# 1889|       PhraseItem longer_item, item;
# 1890|->     for (int i = 0; i < tokenarray->len; ++i) {
# 1891|           phrase_token_t token = g_array_index(tokenarray, phrase_token_t, i);
# 1892|   

Error: COMPILER_WARNING (CWE-1023): [#def9]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp: scope_hint: In function 'bool _compute_phrase_length(pinyin_context_t*, CandidateVector)'
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp:1965:15: warning[-Wswitch]: enumeration value 'LONGER_CANDIDATE' not handled in switch
# 1965 |         switch(candidate->m_candidate_type) {
#      |               ^
# 1963|               (candidates, lookup_candidate_t, i);
# 1964|   
# 1965|->         switch(candidate->m_candidate_type) {
# 1966|           case NBEST_MATCH_CANDIDATE:
# 1967|               abort();

Error: COMPILER_WARNING (CWE-1023): [#def10]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp:1965:15: warning[-Wswitch]: enumeration value 'PREDICTED_PUNCTUATION_CANDIDATE' not handled in switch
# 1963|               (candidates, lookup_candidate_t, i);
# 1964|   
# 1965|->         switch(candidate->m_candidate_type) {
# 1966|           case NBEST_MATCH_CANDIDATE:
# 1967|               abort();

Error: COMPILER_WARNING (CWE-563): [#def11]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp: scope_hint: In function 'bool _compute_predicted_prefix_candidates(pinyin_instance_t*)'
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp:2373:17: warning[-Wunused-variable]: unused variable 'prefixes'
# 2373 |     TokenVector prefixes = instance->m_prefixes;
#      |                 ^~~~~~~~
# 2371|       FacadePhraseIndex * phrase_index = context->m_phrase_index;
# 2372|       CandidateVector candidates = instance->m_candidates;
# 2373|->     TokenVector prefixes = instance->m_prefixes;
# 2374|   
# 2375|       /* search prefix candidate. */

Error: COMPILER_WARNING (CWE-563): [#def12]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp:2381:9: warning[-Wunused-variable]: unused variable 'result'
# 2381 |     int result = context->m_phrase_table->search_suggestion
#      |         ^~~~~~
# 2379|       memset(phrase_tokens, 0, sizeof(phrase_tokens));
# 2380|       phrase_index->prepare_tokens(phrase_tokens);
# 2381|->     int result = context->m_phrase_table->search_suggestion
# 2382|           (instance->m_prefix_len, instance->m_prefix_ucs4, phrase_tokens);
# 2383|       int num = reduce_tokens(phrase_tokens, tokenarray, false);

Error: COMPILER_WARNING (CWE-563): [#def13]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp:2383:9: warning[-Wunused-variable]: unused variable 'num'
# 2383 |     int num = reduce_tokens(phrase_tokens, tokenarray, false);
#      |         ^~~
# 2381|       int result = context->m_phrase_table->search_suggestion
# 2382|           (instance->m_prefix_len, instance->m_prefix_ucs4, phrase_tokens);
# 2383|->     int num = reduce_tokens(phrase_tokens, tokenarray, false);
# 2384|       phrase_index->destroy_tokens(phrase_tokens);
# 2385|   

Error: COMPILER_WARNING (CWE-563): [#def14]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp: scope_hint: In function 'bool pinyin_guess_predicted_candidates(pinyin_instance_t*, const char*)'
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp:2413:25: warning[-Wunused-variable]: unused variable 'phrase_index'
# 2413 |     FacadePhraseIndex * phrase_index = context->m_phrase_index;
#      |                         ^~~~~~~~~~~~
# 2411|                                          const char * prefix) {
# 2412|       pinyin_context_t * context = instance->m_context;
# 2413|->     FacadePhraseIndex * phrase_index = context->m_phrase_index;
# 2414|       CandidateVector candidates = instance->m_candidates;
# 2415|       TokenVector prefixes = instance->m_prefixes;

Error: COMPILER_WARNING (CWE-563): [#def15]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp:2460:25: warning[-Wunused-variable]: unused variable 'phrase_index'
# 2460 |     FacadePhraseIndex * phrase_index = context->m_phrase_index;
#      |                         ^~~~~~~~~~~~
# 2458|   
# 2459|       pinyin_context_t * context = instance->m_context;
# 2460|->     FacadePhraseIndex * phrase_index = context->m_phrase_index;
# 2461|       CandidateVector candidates = instance->m_candidates;
# 2462|       TokenVector prefixes = instance->m_prefixes;

Error: COMPILER_WARNING (CWE-195): [#def16]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp: scope_hint: In function 'bool pinyin_guess_predicted_candidates_with_punctuations(pinyin_instance_t*, const char*)'
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp:2468:32: warning[-Wsign-compare]: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'guint' {aka 'unsigned int'}
# 2468 |     for (gint index = 0; index < prefixes->len; ++index) {
#      |                          ~~~~~~^~~~~~~~~~~~~~~
# 2466|       /* prepend the punctuations */
# 2467|       GArray * punct_array = g_array_new(TRUE, TRUE, sizeof(gchar *));
# 2468|->     for (gint index = 0; index < prefixes->len; ++index) {
# 2469|           prev_token = g_array_index(prefixes, phrase_token_t, index);
# 2470|   

Error: COMPILER_WARNING (CWE-563): [#def17]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp: scope_hint: In function 'int pinyin_choose_candidate(pinyin_instance_t*, size_t, lookup_candidate_t*)'
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp:2578:10: warning[-Wunused-but-set-variable]: variable 'retval' set but not used
# 2578 |     bool retval = constraints->validate_constraint(&matrix);
#      |          ^~~~~~
# 2576|   
# 2577|       /* sync m_constraints to the length of m_pinyin_keys. */
# 2578|->     bool retval = constraints->validate_constraint(&matrix);
# 2579|   
# 2580|       phrase_token_t token = candidate->m_token;

Error: COMPILER_WARNING (CWE-563): [#def18]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp: scope_hint: In function 'bool pinyin_lookup_tokens(pinyin_instance_t*, const char*, GArray*)'
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp:2663:9: warning[-Wunused-variable]: unused variable 'num'
# 2663 |     int num = reduce_tokens(tokens, tokenarray);
#      |         ^~~
# 2661|       phrase_index->prepare_tokens(tokens);
# 2662|       int retval = context->m_phrase_table->search(ucs4_len, ucs4_phrase, tokens);
# 2663|->     int num = reduce_tokens(tokens, tokenarray);
# 2664|       phrase_index->destroy_tokens(tokens);
# 2665|   

Error: COMPILER_WARNING (CWE-563): [#def19]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp: scope_hint: In function 'bool _pre_compute_tokens(pinyin_context_t*, TokenVector, ucs4_t*, size_t)'
libpinyin-2.9.92-build/libpinyin-2.9.92/src/pinyin.cpp:3114:13: warning[-Wunused-variable]: unused variable 'retval'
# 3114 |         int retval = phrase_table->search(1, &character, tokens);
#      |             ^~~~~~
# 3112|   
# 3113|           phrase_index->clear_tokens(tokens);
# 3114|->         int retval = phrase_table->search(1, &character, tokens);
# 3115|   
# 3116|           int num = get_first_token(tokens, token);

Error: COMPILER_WARNING (CWE-563): [#def20]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/storage/ngram_kyotodb.cpp:26: included_from: Included from here.
libpinyin-2.9.92-build/libpinyin-2.9.92/src/storage/kyotodb_utils.h:50:21: warning[-Wunused-variable]: 'pinyin::empty_vbuf' defined but not used
#   50 | static const char * empty_vbuf = (char *)UINTPTR_MAX;
#      |                     ^~~~~~~~~~
#   48|   
#   49|   /* Kyoto Cabinet requires non-NULL pointer for zero length value. */
#   50|-> static const char * empty_vbuf = (char *)UINTPTR_MAX;
#   51|   
#   52|   #if 0

Error: COMPILER_WARNING (CWE-563): [#def21]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/storage/ngram_kyotodb.cpp:26: included_from: Included from here.
libpinyin-2.9.92-build/libpinyin-2.9.92/src/storage/kyotodb_utils.h:50:21: warning[-Wunused-variable]: ‘pinyin::empty_vbuf’ defined but not used
#   50 | static const char * empty_vbuf = (char *)UINTPTR_MAX;
#      |                     ^~~~~~~~~~
#   48|   
#   49|   /* Kyoto Cabinet requires non-NULL pointer for zero length value. */
#   50|-> static const char * empty_vbuf = (char *)UINTPTR_MAX;
#   51|   
#   52|   #if 0

Error: CPPCHECK_WARNING (CWE-476): [#def22]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/storage/pinyin_parser2.cpp:359: warning[nullPointer]: Possible null pointer dereference: curstep
#  357|       }
#  358|       /* prepare saving. */
#  359|->     parsed_len = curstep->m_parsed_len;
#  360|       gint16 num_keys = curstep->m_num_keys;
#  361|       g_array_set_size(keys, num_keys);

Error: CPPCHECK_WARNING (CWE-476): [#def23]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/storage/pinyin_parser2.cpp:360: warning[nullPointer]: Possible null pointer dereference: curstep
#  358|       /* prepare saving. */
#  359|       parsed_len = curstep->m_parsed_len;
#  360|->     gint16 num_keys = curstep->m_num_keys;
#  361|       g_array_set_size(keys, num_keys);
#  362|       g_array_set_size(key_rests, num_keys);

Error: CPPCHECK_WARNING (CWE-476): [#def24]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/storage/pinyin_parser2.cpp:365: warning[nullPointer]: Possible null pointer dereference: curstep
#  363|   
#  364|       /* save the match. */
#  365|->     while (curstep->m_last_step != -1) {
#  366|           gint16 pos = curstep->m_num_keys - 1;
#  367|   

Error: COMPILER_WARNING (CWE-563): [#def25]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/zhuyin.cpp: scope_hint: In function 'bool _add_phrase(zhuyin_context_t*, guint8, ChewingKeyVector, ucs4_t*, glong, gint)'
libpinyin-2.9.92-build/libpinyin-2.9.92/src/zhuyin.cpp:427:9: warning[-Wunused-variable]: unused variable 'num'
#  427 |     int num = reduce_tokens(tokens, tokenarray);
#      |         ^~~
#  425|       phrase_index->prepare_tokens(tokens);
#  426|       int retval = phrase_table->search(phrase_length, phrase, tokens);
#  427|->     int num = reduce_tokens(tokens, tokenarray);
#  428|       phrase_index->destroy_tokens(tokens);
#  429|   

Error: COMPILER_WARNING (CWE-563): [#def26]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/zhuyin.cpp: scope_hint: In function 'void _compute_prefixes(zhuyin_instance_t*, const char*)'
libpinyin-2.9.92-build/libpinyin-2.9.92/src/zhuyin.cpp:933:17: warning[-Wunused-variable]: unused variable 'num'
#  933 |             int num = reduce_tokens(tokens, tokenarray);
#      |                 ^~~
#  931|               phrase_index->prepare_tokens(tokens);
#  932|               int result = context->m_phrase_table->search(i, start, tokens);
#  933|->             int num = reduce_tokens(tokens, tokenarray);
#  934|               phrase_index->destroy_tokens(tokens);
#  935|   

Error: COMPILER_WARNING (CWE-563): [#def27]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/zhuyin.cpp:1638:26: warning[-Wunused-variable]: unused variable 'context'
# 1638 |     zhuyin_context_t * & context = instance->m_context;
#      |                          ^~~~~~~
# 1636|                               size_t offset,
# 1637|                               lookup_candidate_t * candidate){
# 1638|->     zhuyin_context_t * & context = instance->m_context;
# 1639|       PhoneticKeyMatrix & matrix = instance->m_matrix;
# 1640|       ForwardPhoneticConstraints * constraints = instance->m_constraints;

Error: COMPILER_WARNING (CWE-563): [#def28]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/zhuyin.cpp:1641:25: warning[-Wunused-variable]: unused variable 'results'
# 1641 |     NBestMatchResults & results = instance->m_nbest_results;
#      |                         ^~~~~~~
# 1639|       PhoneticKeyMatrix & matrix = instance->m_matrix;
# 1640|       ForwardPhoneticConstraints * constraints = instance->m_constraints;
# 1641|->     NBestMatchResults & results = instance->m_nbest_results;
# 1642|   
# 1643|       if (BEST_MATCH_CANDIDATE == candidate->m_candidate_type)

Error: COMPILER_WARNING (CWE-563): [#def29]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/zhuyin.cpp:1647:10: warning[-Wunused-but-set-variable]: variable 'retval' set but not used
# 1647 |     bool retval = constraints->validate_constraint(&matrix);
#      |          ^~~~~~
# 1645|   
# 1646|       /* sync m_constraints to the length of m_pinyin_keys. */
# 1647|->     bool retval = constraints->validate_constraint(&matrix);
# 1648|   
# 1649|       if (NORMAL_CANDIDATE_AFTER_CURSOR == candidate->m_candidate_type) {

Error: COMPILER_WARNING (CWE-563): [#def30]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/zhuyin.cpp: scope_hint: In function 'int zhuyin_choose_candidate(zhuyin_instance_t*, size_t, lookup_candidate_t*)'
libpinyin-2.9.92-build/libpinyin-2.9.92/src/zhuyin.cpp:1651:16: warning[-Wunused-variable]: unused variable 'len'
# 1651 |         guint8 len = constraints->add_constraint
#      |                ^~~
# 1649|       if (NORMAL_CANDIDATE_AFTER_CURSOR == candidate->m_candidate_type) {
# 1650|           phrase_token_t token = candidate->m_token;
# 1651|->         guint8 len = constraints->add_constraint
# 1652|               (candidate->m_begin, candidate->m_end, token);
# 1653|           offset = candidate->m_end;

Error: COMPILER_WARNING (CWE-563): [#def31]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/zhuyin.cpp:1658:16: warning[-Wunused-variable]: unused variable 'len'
# 1658 |         guint8 len = constraints->add_constraint
#      |                ^~~
# 1656|       if (NORMAL_CANDIDATE_BEFORE_CURSOR == candidate->m_candidate_type) {
# 1657|           phrase_token_t token = candidate->m_token;
# 1658|->         guint8 len = constraints->add_constraint
# 1659|               (candidate->m_begin, candidate->m_end, token);
# 1660|           offset = candidate->m_begin;

Error: COMPILER_WARNING (CWE-563): [#def32]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/zhuyin.cpp: scope_hint: In function 'bool zhuyin_lookup_tokens(zhuyin_instance_t*, const char*, GArray*)'
libpinyin-2.9.92-build/libpinyin-2.9.92/src/zhuyin.cpp:1690:9: warning[-Wunused-variable]: unused variable 'num'
# 1690 |     int num = reduce_tokens(tokens, tokenarray);
#      |         ^~~
# 1688|       phrase_index->prepare_tokens(tokens);
# 1689|       int retval = context->m_phrase_table->search(ucs4_len, ucs4_phrase, tokens);
# 1690|->     int num = reduce_tokens(tokens, tokenarray);
# 1691|       phrase_index->destroy_tokens(tokens);
# 1692|   

Error: COMPILER_WARNING (CWE-563): [#def33]
libpinyin-2.9.92-build/libpinyin-2.9.92/src/zhuyin.cpp: scope_hint: In function 'bool _pre_compute_tokens(zhuyin_context_t*, TokenVector, ucs4_t*, size_t)'
libpinyin-2.9.92-build/libpinyin-2.9.92/src/zhuyin.cpp:2078:13: warning[-Wunused-variable]: unused variable 'retval'
# 2078 |         int retval = phrase_table->search(1, &character, tokens);
#      |             ^~~~~~
# 2076|   
# 2077|           phrase_index->clear_tokens(tokens);
# 2078|->         int retval = phrase_table->search(1, &character, tokens);
# 2079|   
# 2080|           int num = get_first_token(tokens, token);

Error: COMPILER_WARNING (CWE-195): [#def34]
libpinyin-2.9.92-build/libpinyin-2.9.92/tests/storage/test_phrase_table.cpp: scope_hint: In function ‘int main(int, char**)’
libpinyin-2.9.92-build/libpinyin-2.9.92/tests/storage/test_phrase_table.cpp:67:23: warning[-Wsign-compare]: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘glong’ {aka ‘long int’}
#   67 |         for (i = 1; i < phrase_len; ++i) {
#      |                     ~~^~~~~~~~~~~~
#   65|           /* test search continued information. */
#   66|           int retval = SEARCH_NONE;
#   67|->         for (i = 1; i < phrase_len; ++i) {
#   68|               phrase_index.clear_tokens(tokens);
#   69|               retval = largetable.search(i, new_phrase, tokens);

Error: COMPILER_WARNING (CWE-563): [#def35]
libpinyin-2.9.92-build/libpinyin-2.9.92/utils/segment/mergeseq.cpp: scope_hint: In function ‘bool merge_sequence(pinyin::FacadePhraseTable3*, pinyin::FacadePhraseIndex*, UnicodeCharVector, TokenInfoVector)’
libpinyin-2.9.92-build/libpinyin-2.9.92/utils/segment/mergeseq.cpp:99:17: warning[-Wunused-variable]: unused variable ‘num’
#   99 |             int num = get_first_token(tokens, token);
#      |                 ^~~
#   97|   
#   98|           if (retval & SEARCH_OK) {
#   99|->             int num = get_first_token(tokens, token);
#  100|               found = true;
#  101|               break;

Error: COMPILER_WARNING (CWE-563): [#def36]
libpinyin-2.9.92-build/libpinyin-2.9.92/utils/segment/spseg.cpp: scope_hint: In function ‘bool segment(pinyin::FacadePhraseTable3*, pinyin::FacadePhraseIndex*, GArray*, GArray*)’
libpinyin-2.9.92-build/libpinyin-2.9.92/utils/segment/spseg.cpp:114:17: warning[-Wunused-variable]: unused variable ‘num’
#  114 |             int num = get_first_token(tokens, token);
#      |                 ^~~
#  112|               phrase_index->clear_tokens(tokens);
#  113|               int result = phrase_table->search(len, cur_phrase, tokens);
#  114|->             int num = get_first_token(tokens, token);
#  115|   
#  116|               if ( !(result & SEARCH_OK) ){

Error: COMPILER_WARNING (CWE-563): [#def37]
libpinyin-2.9.92-build/libpinyin-2.9.92/utils/storage/gen_zhuyin_table.cpp: scope_hint: In function ‘void gen_phrase_file(const char*, int)’
libpinyin-2.9.92-build/libpinyin-2.9.92/utils/storage/gen_zhuyin_table.cpp:311:36: warning[-Wunused-but-set-variable]: variable ‘key_rest’ set but not used
#  311 |                     ChewingKeyRest key_rest = g_array_index
#      |                                    ^~~~~~~~
#  309|                   for (k = 0; k < keys->len; ++k) {
#  310|                       ChewingKey key = g_array_index(keys, ChewingKey, k);
#  311|->                     ChewingKeyRest key_rest = g_array_index
#  312|                           (key_rests, ChewingKeyRest, k);
#  313|   

Error: COMPILER_WARNING (CWE-563): [#def38]
libpinyin-2.9.92-build/libpinyin-2.9.92/utils/training/estimate_interpolation.cpp: scope_hint: In function ‘parameter_t compute_interpolation(pinyin::SingleGram*, pinyin::FacadePhraseIndex*, pinyin::SingleGram*)’
libpinyin-2.9.92-build/libpinyin-2.9.92/utils/training/estimate_interpolation.cpp:33:10: warning[-Wunused-variable]: unused variable ‘success’
#   33 |     bool success;
#      |          ^~~~~~~
#   31|   				  FacadePhraseIndex * unigram,
#   32|   				  SingleGram * bigram){
#   33|->     bool success;
#   34|       parameter_t lambda = 0, next_lambda = 0.6;
#   35|       parameter_t epsilon = 0.001;

Error: COMPILER_WARNING (CWE-563): [#def39]
libpinyin-2.9.92-build/libpinyin-2.9.92/utils/training/estimate_k_mixture_model.cpp: scope_hint: In function ‘parameter_t compute_interpolation(pinyin::KMixtureModelSingleGram*, pinyin::KMixtureModelBigram*, pinyin::KMixtureModelSingleGram*)’
libpinyin-2.9.92-build/libpinyin-2.9.92/utils/training/estimate_k_mixture_model.cpp:39:10: warning[-Wunused-variable]: unused variable ‘success’
#   39 |     bool success;
#      |          ^~~~~~~
#   37|                                     KMixtureModelBigram * unigram,
#   38|                                     KMixtureModelSingleGram * bigram){
#   39|->     bool success;
#   40|       parameter_t lambda = 0, next_lambda = 0.6;
#   41|       parameter_t epsilon = 0.001;

Error: COMPILER_WARNING (CWE-195): [#def40]
libpinyin-2.9.92-build/libpinyin-2.9.92/utils/training/gen_k_mixture_model.cpp: scope_hint: In function ‘void train_word_pair(HashofUnigram, pinyin::KMixtureModelSingleGram*, phrase_token_t, guint32)’
libpinyin-2.9.92-build/libpinyin-2.9.92/utils/training/gen_k_mixture_model.cpp:184:20: warning[-Wsign-compare]: comparison of integer expressions of different signedness: ‘guint32’ {aka ‘unsigned int’} and ‘gint’ {aka ‘int’}
#  184 |         if ( count > g_maximum_occurs ){
#      |              ~~~~~~^~~~~~~~~~~~~~~~~~
#  182|       } else { /* item doesn't exist. */
#  183|           /* the same as above. */
#  184|->         if ( count > g_maximum_occurs ){
#  185|               gpointer value = NULL;
#  186|               check_result(g_hash_table_lookup_extended

Error: COMPILER_WARNING (CWE-563): [#def41]
libpinyin-2.9.92-build/libpinyin-2.9.92/utils/training/gen_k_mixture_model.cpp: scope_hint: In function ‘bool post_processing_unigram(pinyin::KMixtureModelBigram*, HashofUnigram)’
libpinyin-2.9.92-build/libpinyin-2.9.92/utils/training/gen_k_mixture_model.cpp:302:14: warning[-Wunused-variable]: unused variable ‘result’
#  302 |         bool result = bigram->get_array_header(token, array_header);
#      |              ^~~~~~
#  300|           guint32 freq = GPOINTER_TO_UINT(value);
#  301|           KMixtureModelArrayHeader array_header;
#  302|->         bool result = bigram->get_array_header(token, array_header);
#  303|           array_header.m_freq += freq;
#  304|           total_freq += freq;

Error: COMPILER_WARNING (CWE-563): [#def42]
libpinyin-2.9.92-build/libpinyin-2.9.92/utils/training/prune_k_mixture_model.cpp: scope_hint: In function ‘bool prune_k_mixture_model(pinyin::KMixtureModelMagicHeader*, pinyin::KMixtureModelSingleGram*&, pinyin::FlexibleBigramPhraseArray)’
libpinyin-2.9.92-build/libpinyin-2.9.92/utils/training/prune_k_mixture_model.cpp:48:10: warning[-Wunused-variable]: unused variable ‘success’
#   48 |     bool success;
#      |          ^~~~~~~
#   46|                              KMixtureModelSingleGram * & bigram,
#   47|                              FlexibleBigramPhraseArray removed_array){
#   48|->     bool success;
#   49|   
#   50|       FlexibleBigramPhraseArray array = g_array_new(FALSE, FALSE, sizeof(KMixtureModelArrayItemWithToken));

Scan Properties

analyzer-version-clippy1.82.0
analyzer-version-cppcheck2.16.0
analyzer-version-gcc14.2.1
analyzer-version-gcc-analyzer15.0.0
analyzer-version-shellcheck0.10.0
analyzer-version-unicontrol0.0.2
enabled-pluginsclippy, cppcheck, gcc, shellcheck, unicontrol
exit-code0
hostip-172-16-1-243.us-west-2.compute.internal
mock-configfedora-rawhide-gcc-latest-x86_64
project-namelibpinyin-2.9.92-1.fc42
store-results-to/tmp/tmp3q9j5c6d/libpinyin-2.9.92-1.fc42.tar.xz
time-created2024-11-13 01:42:52
time-finished2024-11-13 01:46:18
toolcsmock
tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-gcc-latest-x86_64' '-t' 'clippy,cppcheck,gcc,unicontrol,shellcheck' '-o' '/tmp/tmp3q9j5c6d/libpinyin-2.9.92-1.fc42.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install=gcc-latest' '--gcc-analyzer-bin=/opt/gcc-latest/bin/gcc' '/tmp/tmp3q9j5c6d/libpinyin-2.9.92-1.fc42.src.rpm'
tool-versioncsmock-3.7.1.20241107.094801.gb3f0f26.pr_192-1.el9