Project

General

Profile

Actions

Bug #2319

open

improve error message when secfile not found

Added by Dean Brown 13 days ago. Updated 8 days ago.

Status:
In Review
Priority:
Normal
Category:
Server
Target version:
Start date:
10/02/2026
Due date:
% Done:

0%

Estimated time:

Description

From server prompt, enter "load foo.sav" where "foo.sav" file does not exist. Get error message -

1: Error loading savefile '33c2c3.sav': In secfile_lookup_str_vec() [../utility/registry_ini.c:2531]: secfile '/Applications/Freeciv.app/Contents/share/freeciv/civ2civ3/game.ruleset' in section 'nullptr': "goods_good.helptext" entry doesn't exist.

The part -

...civ2civ3/game.ruleset' in section 'nullptr': "goods_good.helptext" entry doesn't exist.

is bogus. What's happening is that secfile_load() returns NULL if the file is not found, as well as when there's a secfile parse error. The calling routine tests secfile_load() return value and if it's null, calls "log_debug("Error reading '%s':\n%s", ... secfile_error());" and secfile_error() returns the most recent leftover secfile parse error, which is irrelevant when the file is not found. So some calls to secfile_load() should be preceded by calls to fc_stat() to give better error messages.


Files

2319_Part2.patch (960 Bytes) 2319_Part2.patch Dean Brown, 10/06/2026 05:48 AM
2319_Main_Part1.patch (1.91 KB) 2319_Main_Part1.patch Dean Brown, 10/06/2026 05:48 AM
2319_S3_3_Part1.patch (1.91 KB) 2319_S3_3_Part1.patch Dean Brown, 10/06/2026 05:48 AM

Related issues 2 (2 open — 0 closed)

Blocks Feature #2340: fc_stat(): Accept nullptr bufferNew10/06/2026

Actions
Blocked by Feature #2323: fcdb.c : NULL -> nullptrIn ReviewMarko Lindqvist10/04/2026

Actions
Actions #1

Updated by Dean Brown 13 days ago

  • File 2319_Main_Part1.patch added
  • File 2319_Part2.patch added
  • File 2319_S3_3_Part1.patch added

Looking for other instances, in most other cases the file's existence has already been tested before the call to secfile_load(). In addition to the call in stdinhand.c routine load_command(), there's one in fcdb.c routine fcdb_load_config() to be fixed. I'm unclear about the one in gamehand.c routine handle_single_want_hack_req() - a fc_stat() test here may be redundant, so I put that in a separate patch.

Actions #2

Updated by Marko Lindqvist 9 days ago

Main patch conflicts with #2323 - please rebase on top of that.

Actions #3

Updated by Marko Lindqvist 9 days ago

Maybe you should use fc_strerror(fc_get_errno()) instead of blindly claiming that the error is "file not found"

Actions #4

Updated by Dean Brown 9 days ago

  • File deleted (2319_Part2.patch)
Actions #5

Updated by Dean Brown 9 days ago

  • File deleted (2319_Main_Part1.patch)
Actions #6

Updated by Dean Brown 9 days ago

  • File deleted (2319_S3_3_Part1.patch)

Updated by Dean Brown 9 days ago

Thanks for the tip about fc_strerror(fc_get_errno())

Actions #8

Updated by Marko Lindqvist 9 days ago

  • Tracker changed from Feature to Bug

Considering the wrong error message a bug.

Actions #9

Updated by Marko Lindqvist 8 days ago

  • Status changed from New to In Review
  • Assignee set to Marko Lindqvist
  • Target version set to 3.2.7
Actions #10

Updated by Marko Lindqvist 8 days ago

Actions #11

Updated by Marko Lindqvist 7 days ago

Actions

Also available in: Atom PDF