refactor: address PR #105 review feedback

Apply fixes, refactors and test additions requested by reviewer on PR #105.

Fixes:
- database: warn and notify user on duplicate archive_id instead of
  silently debug-logging it (R05).
- database: add missing '[' in "[DB Migration]" log prefix (R06).
- xmpp/resource: NULL-out name/status after g_free to avoid double-free
  via roster_list.c cleanup path (R09, R23).
- common: widen strtoi_range internal storage from int to long so that
  values in (INT_MAX, LONG_MAX] are rejected as out-of-range instead of
  being silently truncated on 64-bit platforms (R25).

Refactors:
- xmpp/message: extract _receive_omemo helper, removing three copies of
  the OMEMO receive block in groupchat / MUC-PM / chat handlers (R04).
- omemo: flatten deeply nested device-list processing via guard-clause
  continues (R11).
- tools/autocomplete: merge two nested ifs into a single && condition
  (R13).
- ui/titlebar: extract _show_trust_indicator and inline _wprintw_withattr
  wrapper, collapsing three near-identical trust-indicator blocks (R22).
- config/tlscerts: drop _checked_g_strdup wrapper; g_strdup is
  NULL-safe per glib documentation (R19).
- ui/inputwin: use auto_gchar for spellcheck word instead of manual
  g_free (R20).
- tools/editor: drop outdated "Deprecated synchronous" comment that
  no longer matches the callback-based implementation (R28).

Tests:
- tests/command/cmd_ac: rename segfaults_when_empty ->
  no_segfault_when_empty; expand cycling coverage to three files plus
  backward SHIFT-TAB traversal (R16, R17).
- tests/common: add strtoi_range overflow/underflow and strtol-parsing
  consistency tests (R25).
- tests/xmpp/jid: add test for '@' inside resourcepart per RFC 6122
  section 2.4 (R26).

Misc:
- xmpp/omemo: change omemo_error_to_string return type from char* to
  gchar* for glib consistency (R01).
- subprojects/libstrophe: point wrap-git at our fork at
  git.jabber.space/devs/libstrophe-gh (R24).
- RELEASE_GUIDE: drop "Updating website" section referring to an
  upstream site that is not ours (R18).
This commit is contained in:
2026-04-24 15:13:38 +03:00
parent a5fe32b245
commit 4401e817d0
21 changed files with 181 additions and 165 deletions

View File

@@ -107,7 +107,7 @@ main(int argc, char* argv[])
cmocka_unit_test(unique_filename_from_url__tests__table_driven),
cmocka_unit_test(string_to_verbosity__returns__correct_values),
cmocka_unit_test(get_expanded_path__returns__expanded),
cmocka_unit_test_setup_teardown(cmd_ac_complete_filepath__segfaults_when_empty, load_preferences, close_preferences),
cmocka_unit_test_setup_teardown(cmd_ac_complete_filepath__no_segfault_when_empty, load_preferences, close_preferences),
cmocka_unit_test_setup_teardown(cmd_ac_complete_filepath__finds_files_in_current_dir, load_preferences, close_preferences),
cmocka_unit_test_setup_teardown(cmd_ac_complete_filepath__finds_files_with_dot_slash, load_preferences, close_preferences),
cmocka_unit_test_setup_teardown(cmd_ac_complete_filepath__cycles_through_files, load_preferences, close_preferences),
@@ -116,6 +116,8 @@ main(int argc, char* argv[])
cmocka_unit_test(strtoi_range__returns__false_for_invalid_input),
cmocka_unit_test(strtoi_range__returns__false_for_null_empty_input),
cmocka_unit_test(strtoi_range__returns__correct_values_when_err_msg_null),
cmocka_unit_test(strtoi_range__returns__false_for_integer_overflow_underflow),
cmocka_unit_test(strtoi_range__returns_consistent_with_strtol_parsing),
cmocka_unit_test(string_matches_one_of__tests__edge_cases),
cmocka_unit_test(valid_tls_policy_option__is__correct_for_various_inputs),
cmocka_unit_test(autocomplete_complete__returns__null_when_empty),
@@ -175,6 +177,7 @@ main(int argc, char* argv[])
cmocka_unit_test(jid_create__returns__null_from_multiple_at_in_bare),
cmocka_unit_test(jid_create__returns__correct_parts_with_at_in_resource_only),
cmocka_unit_test(jid_is_valid_user_jid__is__true_for_valid_user_jid),
cmocka_unit_test(jid_is_valid_user_jid__is__true_for_at_in_resource),
cmocka_unit_test(jid_is_valid_user_jid__is__false_for_domain_jid),
cmocka_unit_test(jid_is_valid_user_jid__is__false_for_invalid_jid),
cmocka_unit_test(jid_is_valid__is__true_for_valid_jid),