From: Jon Turney <jon.turney@dronecode.org.uk>
To: cygwin-apps@cygwin.com
Cc: Jon Turney <jon.turney@dronecode.org.uk>
Subject: [PATCH setup 1/5] Make do_ini() succeed if found_ini_list is empty
Date: Tue, 07 Nov 2017 18:17:00 -0000 [thread overview]
Message-ID: <20171107181703.51016-1-jon.turney@dronecode.org.uk> (raw)
In-Reply-To: <aa7da561-29e2-4789-9d47-0901ad6228d2@dronecode.org.uk>
Rather than count the number of .ini files read in do_{local,remote}_ini,
and assume success if greater than zero, actually track if an error occured.
This is a subtle change of behaviour if more than one .ini file is read:
previously all we needed was one to succeed, now we need them all to
succeed.
(Note that site_list should never be empty, and it's still an error if we
don't find an .ini file from a site, to the practical effect is to make
do_local_ini with an empty found_ini_list succeed)
---
ini.cc | 39 ++++++++++++++++++++-------------------
1 file changed, 20 insertions(+), 19 deletions(-)
diff --git a/ini.cc b/ini.cc
index 0f8b927..85325c3 100644
--- a/ini.cc
+++ b/ini.cc
@@ -205,10 +205,10 @@ check_ini_sig (io_stream* ini_file, io_stream* ini_sig_file,
return ini_file;
}
-static int
+static bool
do_local_ini (HWND owner)
{
- size_t ini_count = 0;
+ bool ini_error = false;
GuiParseFeedback myFeedback;
IniDBBuilderPackage aBuilder (myFeedback);
io_stream *ini_file, *ini_sig_file;
@@ -233,6 +233,7 @@ do_local_ini (HWND owner)
// no setup found or signature invalid
note (owner, IDS_SETUPINI_MISSING, SetupBaseName.c_str (),
"localdir");
+ ini_error = true;
}
else
{
@@ -245,12 +246,11 @@ do_local_ini (HWND owner)
rfc1738_unescape (current_ini_name.substr (ldl, cap - ldl));
ini_init (ini_file, &aBuilder, myFeedback);
- /*yydebug = 1; */
-
if (yyparse () || yyerror_count > 0)
- myFeedback.error (yyerror_messages);
- else
- ++ini_count;
+ {
+ myFeedback.error (yyerror_messages);
+ ini_error = true;
+ }
if (aBuilder.timestamp > setup_timestamp)
{
@@ -261,13 +261,13 @@ do_local_ini (HWND owner)
ini_file = NULL;
}
}
- return ini_count;
+ return ini_error;
}
-static int
+static bool
do_remote_ini (HWND owner)
{
- size_t ini_count = 0;
+ bool ini_error = false;
GuiParseFeedback myFeedback;
IniDBBuilderPackage aBuilder (myFeedback);
io_stream *ini_file = NULL, *ini_sig_file;
@@ -303,6 +303,7 @@ do_remote_ini (HWND owner)
{
// no setup found or signature invalid
note (owner, IDS_SETUPINI_MISSING, SetupBaseName.c_str (), n->url.c_str ());
+ ini_error = true;
}
else
{
@@ -311,10 +312,11 @@ do_remote_ini (HWND owner)
aBuilder.parse_mirror = n->url;
ini_init (ini_file, &aBuilder, myFeedback);
- /*yydebug = 1; */
-
if (yyparse () || yyerror_count > 0)
- myFeedback.error (yyerror_messages);
+ {
+ myFeedback.error (yyerror_messages);
+ ini_error = true;
+ }
else
{
/* save known-good setup.ini locally */
@@ -329,7 +331,6 @@ do_remote_ini (HWND owner)
io_stream::remove (fp);
delete out;
}
- ++ini_count;
}
if (aBuilder.timestamp > setup_timestamp)
{
@@ -340,19 +341,19 @@ do_remote_ini (HWND owner)
ini_file = NULL;
}
}
- return ini_count;
+ return ini_error;
}
static bool
do_ini_thread (HINSTANCE h, HWND owner)
{
- size_t ini_count = 0;
+ bool ini_error = true;
if (source == IDC_SOURCE_LOCALDIR)
- ini_count = do_local_ini (owner);
+ ini_error = do_local_ini (owner);
else
- ini_count = do_remote_ini (owner);
+ ini_error = do_remote_ini (owner);
- if (ini_count == 0)
+ if (ini_error)
return false;
if (get_root_dir ().c_str ())
--
2.15.0
next prev parent reply other threads:[~2017-11-07 18:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-01 20:38 [setup topic/libsolv] Crash after incomplete download Ken Brown
2017-11-02 17:22 ` Jon Turney
2017-11-02 19:25 ` Ken Brown
2017-11-07 18:15 ` Jon Turney
2017-11-07 18:17 ` Jon Turney [this message]
2017-11-07 18:17 ` [PATCH setup 5/5] More crash avoidance in SolvableVersion member functions Jon Turney
2017-11-07 18:17 ` [PATCH setup 2/5] Simplify LocalDirPage::OnNext() Jon Turney
2017-11-07 18:17 ` [PATCH setup 4/5] Correctly order preparing packagedb for chooser Jon Turney
2017-11-07 18:17 ` [PATCH setup 3/5] Ensure packagedb and underlying solver pool is empty before we read setup.ini Jon Turney
2017-11-07 23:00 ` [setup topic/libsolv] Crash after incomplete download Ken Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171107181703.51016-1-jon.turney@dronecode.org.uk \
--to=jon.turney@dronecode.org.uk \
--cc=cygwin-apps@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).