Use EXIT_FAILURE/SUCCESS
This commit is contained in:
committed by
Louis-Bertrand Varin
parent
bf9b23539e
commit
9b92e7f8e8
@@ -15,6 +15,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "Merge.h"
|
||||
|
||||
#include <QCommandLineParser>
|
||||
@@ -48,7 +50,7 @@ int Merge::execute(int argc, char** argv)
|
||||
const QStringList args = parser.positionalArguments();
|
||||
if (args.size() != 2) {
|
||||
parser.showHelp();
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
static QTextStream inputTextStream(stdin, QIODevice::ReadOnly);
|
||||
@@ -70,11 +72,11 @@ int Merge::execute(int argc, char** argv)
|
||||
QFile dbFile1(databaseFilename1);
|
||||
if (!dbFile1.exists()) {
|
||||
qCritical("File %s does not exist.", qPrintable(databaseFilename1));
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (!dbFile1.open(QIODevice::ReadOnly)) {
|
||||
qCritical("Unable to open file %s.", qPrintable(databaseFilename1));
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
KeePass2Reader reader1;
|
||||
@@ -82,7 +84,7 @@ int Merge::execute(int argc, char** argv)
|
||||
|
||||
if (reader1.hasError()) {
|
||||
qCritical("Error while parsing the database:\n%s\n", qPrintable(reader1.errorString()));
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,11 +92,11 @@ int Merge::execute(int argc, char** argv)
|
||||
QFile dbFile2(databaseFilename2);
|
||||
if (!dbFile2.exists()) {
|
||||
qCritical("File %s does not exist.", qPrintable(databaseFilename2));
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (!dbFile2.open(QIODevice::ReadOnly)) {
|
||||
qCritical("Unable to open file %s.", qPrintable(databaseFilename2));
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
KeePass2Reader reader2;
|
||||
@@ -102,7 +104,7 @@ int Merge::execute(int argc, char** argv)
|
||||
|
||||
if (reader2.hasError()) {
|
||||
qCritical("Error while parsing the database:\n%s\n", qPrintable(reader2.errorString()));
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
db1->merge(db2);
|
||||
@@ -110,7 +112,7 @@ int Merge::execute(int argc, char** argv)
|
||||
QSaveFile saveFile(databaseFilename1);
|
||||
if (!saveFile.open(QIODevice::WriteOnly)) {
|
||||
qCritical("Unable to open file %s for writing.", qPrintable(databaseFilename1));
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
KeePass2Writer writer;
|
||||
@@ -118,15 +120,15 @@ int Merge::execute(int argc, char** argv)
|
||||
|
||||
if (writer.hasError()) {
|
||||
qCritical("Error while updating the database:\n%s\n", qPrintable(writer.errorString()));
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (!saveFile.commit()) {
|
||||
qCritical("Error while updating the database:\n%s\n", qPrintable(writer.errorString()));
|
||||
return 0;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
qDebug("Successfully merged the database files.\n");
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user