1 | A bunch of functions (like read and write) return status values. They should be checked. |
---|
2 | |
---|
3 | From: Erik Hovland <erik@hovland.org> |
---|
4 | |
---|
5 | |
---|
6 | --- |
---|
7 | |
---|
8 | mythtv/libs/libmyth/dbutil.cpp | 16 ++++++++++------ |
---|
9 | mythtv/libs/libmyth/mythcdrom-linux.cpp | 5 ++++- |
---|
10 | mythtv/libs/libmyth/mythcontext.cpp | 22 ++++++++++++++++++---- |
---|
11 | mythtv/libs/libmyth/remoteutil.cpp | 8 +++++--- |
---|
12 | mythtv/libs/libmyth/remoteutil.h | 2 +- |
---|
13 | 5 files changed, 38 insertions(+), 15 deletions(-) |
---|
14 | |
---|
15 | |
---|
16 | diff --git a/mythtv/libs/libmyth/dbutil.cpp b/mythtv/libs/libmyth/dbutil.cpp |
---|
17 | index 7fd9949..10c86b5 100644 |
---|
18 | --- a/mythtv/libs/libmyth/dbutil.cpp |
---|
19 | +++ b/mythtv/libs/libmyth/dbutil.cpp |
---|
20 | @@ -219,9 +219,11 @@ bool DBUtil::BackupDB(QString &filename) |
---|
21 | bool result = false; |
---|
22 | MSqlQuery query(MSqlQuery::InitCon()); |
---|
23 | |
---|
24 | - gContext->SaveSettingOnHost("BackupDBLastRunStart", |
---|
25 | - QDateTime::currentDateTime() |
---|
26 | - .toString("yyyy-MM-dd hh:mm:ss"), NULL); |
---|
27 | + result = gContext->SaveSettingOnHost("BackupDBLastRunStart", |
---|
28 | + QDateTime::currentDateTime() |
---|
29 | + .toString("yyyy-MM-dd hh:mm:ss"), NULL); |
---|
30 | + if (!result) |
---|
31 | + VERBOSE(VB_IMPORTANT, "SaveSettingOnHost failed."); |
---|
32 | |
---|
33 | if (!backupScript.isEmpty()) |
---|
34 | { |
---|
35 | @@ -234,9 +236,11 @@ bool DBUtil::BackupDB(QString &filename) |
---|
36 | if (!result) |
---|
37 | result = DoBackup(filename); |
---|
38 | |
---|
39 | - gContext->SaveSettingOnHost("BackupDBLastRunEnd", |
---|
40 | - QDateTime::currentDateTime() |
---|
41 | - .toString("yyyy-MM-dd hh:mm:ss"), NULL); |
---|
42 | + result = gContext->SaveSettingOnHost("BackupDBLastRunEnd", |
---|
43 | + QDateTime::currentDateTime() |
---|
44 | + .toString("yyyy-MM-dd hh:mm:ss"), NULL); |
---|
45 | + if (!result) |
---|
46 | + VERBOSE(VB_IMPORTANT, "SaveSettingOnHost failed."); |
---|
47 | |
---|
48 | if (query.isConnected()) |
---|
49 | { |
---|
50 | diff --git a/mythtv/libs/libmyth/mythcdrom-linux.cpp b/mythtv/libs/libmyth/mythcdrom-linux.cpp |
---|
51 | index 600eb1c..72669a9 100644 |
---|
52 | --- a/mythtv/libs/libmyth/mythcdrom-linux.cpp |
---|
53 | +++ b/mythtv/libs/libmyth/mythcdrom-linux.cpp |
---|
54 | @@ -285,7 +285,10 @@ int MythCDROMLinux::SCSIstatus() |
---|
55 | MediaError MythCDROMLinux::eject(bool open_close) |
---|
56 | { |
---|
57 | if (!isDeviceOpen()) |
---|
58 | - openDevice(); |
---|
59 | + { |
---|
60 | + if (!openDevice()) |
---|
61 | + return MEDIAERR_FAILED; |
---|
62 | + } |
---|
63 | |
---|
64 | if (open_close) |
---|
65 | return (ioctl(m_DeviceHandle, CDROMEJECT) == 0) ? MEDIAERR_OK |
---|
66 | diff --git a/mythtv/libs/libmyth/mythcontext.cpp b/mythtv/libs/libmyth/mythcontext.cpp |
---|
67 | index 31dc942..006fb50 100644 |
---|
68 | --- a/mythtv/libs/libmyth/mythcontext.cpp |
---|
69 | +++ b/mythtv/libs/libmyth/mythcontext.cpp |
---|
70 | @@ -1026,7 +1026,11 @@ int MythContextPrivate::ChooseBackend(const QString &error) |
---|
71 | switch (selected) |
---|
72 | { |
---|
73 | case kDialogCodeButton0: |
---|
74 | - WriteSettingsFile(m_DBparams, true); |
---|
75 | + if (!WriteSettingsFile(m_DBparams, true)) |
---|
76 | + { |
---|
77 | + VERBOSE(VB_IMPORTANT, "WriteSettingsFile failed."); |
---|
78 | + return -1; |
---|
79 | + } |
---|
80 | // User prefers mysql.txt, so throw away default UPnP backend: |
---|
81 | m_XML->SetValue(kDefaultUSN, ""); |
---|
82 | m_XML->Save(); |
---|
83 | @@ -1866,8 +1870,10 @@ QString MythContext::GetMasterHostPrefix(void) |
---|
84 | { |
---|
85 | d->serverSockLock.lock(); |
---|
86 | bool blockingClient = gContext->GetNumSetting("idleTimeoutSecs",0) > 0; |
---|
87 | - ConnectToMasterServer(blockingClient); |
---|
88 | + bool retVal = ConnectToMasterServer(blockingClient); |
---|
89 | d->serverSockLock.unlock(); |
---|
90 | + if (!retVal) |
---|
91 | + return ret; |
---|
92 | } |
---|
93 | |
---|
94 | if (d->serverSock) |
---|
95 | @@ -2016,7 +2022,11 @@ bool MythContext::SendReceiveStringList(QStringList &strlist, |
---|
96 | if (!d->serverSock) |
---|
97 | { |
---|
98 | bool blockingClient = gContext->GetNumSetting("idleTimeoutSecs",0) > 0; |
---|
99 | - ConnectToMasterServer(blockingClient); |
---|
100 | + if (!ConnectToMasterServer(blockingClient)) |
---|
101 | + { |
---|
102 | + d->serverSockLock.unlock(); |
---|
103 | + return false; |
---|
104 | + } |
---|
105 | } |
---|
106 | |
---|
107 | bool ok = false; |
---|
108 | @@ -2033,7 +2043,11 @@ bool MythContext::SendReceiveStringList(QStringList &strlist, |
---|
109 | d->serverSock = NULL; |
---|
110 | |
---|
111 | bool blockingClient = gContext->GetNumSetting("idleTimeoutSecs",0) > 0; |
---|
112 | - ConnectToMasterServer(blockingClient); |
---|
113 | + if (!ConnectToMasterServer(blockingClient)) |
---|
114 | + { |
---|
115 | + d->serverSockLock.unlock(); |
---|
116 | + return false; |
---|
117 | + } |
---|
118 | |
---|
119 | if (d->serverSock) |
---|
120 | { |
---|
121 | diff --git a/mythtv/libs/libmyth/remoteutil.cpp b/mythtv/libs/libmyth/remoteutil.cpp |
---|
122 | index 9cb7724..1624f18 100644 |
---|
123 | --- a/mythtv/libs/libmyth/remoteutil.cpp |
---|
124 | +++ b/mythtv/libs/libmyth/remoteutil.cpp |
---|
125 | @@ -183,10 +183,10 @@ void RemoteGetAllScheduledRecordings(vector<ProgramInfo *> &scheduledlist) |
---|
126 | RemoteGetRecordingList(&scheduledlist, strList); |
---|
127 | } |
---|
128 | |
---|
129 | -void RemoteGetAllExpiringRecordings(vector<ProgramInfo *> &expiringlist) |
---|
130 | +int RemoteGetAllExpiringRecordings(vector<ProgramInfo *> &expiringlist) |
---|
131 | { |
---|
132 | QStringList strList(QString("QUERY_GETEXPIRING")); |
---|
133 | - RemoteGetRecordingList(&expiringlist, strList); |
---|
134 | + return RemoteGetRecordingList(&expiringlist, strList); |
---|
135 | } |
---|
136 | |
---|
137 | int RemoteGetRecordingList(vector<ProgramInfo *> *reclist, QStringList &strList) |
---|
138 | @@ -224,7 +224,9 @@ vector<ProgramInfo *> *RemoteGetConflictList(const ProgramInfo *pginfo) |
---|
139 | |
---|
140 | vector<ProgramInfo *> *retlist = new vector<ProgramInfo *>; |
---|
141 | |
---|
142 | - RemoteGetRecordingList(retlist, strlist); |
---|
143 | + if (!RemoteGetRecordingList(retlist, strlist)) |
---|
144 | + retlist->clear(); |
---|
145 | + |
---|
146 | return retlist; |
---|
147 | } |
---|
148 | |
---|
149 | diff --git a/mythtv/libs/libmyth/remoteutil.h b/mythtv/libs/libmyth/remoteutil.h |
---|
150 | index 0cdd4e6..7ab1867 100644 |
---|
151 | --- a/mythtv/libs/libmyth/remoteutil.h |
---|
152 | +++ b/mythtv/libs/libmyth/remoteutil.h |
---|
153 | @@ -44,7 +44,7 @@ bool RemoteUndeleteRecording(const ProgramInfo *pginfo); |
---|
154 | MPUBLIC |
---|
155 | void RemoteGetAllScheduledRecordings(vector<ProgramInfo *> &scheduledlist); |
---|
156 | MPUBLIC |
---|
157 | -void RemoteGetAllExpiringRecordings(vector<ProgramInfo *> &expiringlist); |
---|
158 | +int RemoteGetAllExpiringRecordings(vector<ProgramInfo *> &expiringlist); |
---|
159 | MPUBLIC int RemoteGetRecordingList(vector<ProgramInfo *> *reclist, |
---|
160 | QStringList &strList); |
---|
161 | MPUBLIC vector<ProgramInfo *> *RemoteGetConflictList(const ProgramInfo *pginfo); |
---|