Bug Summary

File:libsynthesis/src/sysync_SDK/Sources/enginemodulebase.cpp
Warning:line 116, column 5
Value stored to 'err' is never read

Annotated Source Code

1/**
2 * @File enginemodulebase.cpp
3 *
4 * @Author Beat Forster (bfo@synthesis.ch)
5 *
6 * @brief TEngineModuleBase
7 * engine bus bar class
8 *
9 * Copyright (c) 2007-2011 by Synthesis AG + plan44.ch
10 *
11 */
12
13
14#include "prefix_file.h"
15#include "enginemodulebase.h"
16#include "SDK_util.h"
17
18#if defined SYSYNC_ENGINE || defined SYSYNC_ENGINE_TEST
19 #include "engineentry.h"
20#endif
21
22#if !defined(SYSYNC_ENGINE) || defined(ENGINEINTERFACE_SUPPORT)
23
24namespace sysync {
25
26
27
28// TEngineModuleBase
29// =================
30
31// local name
32#define MyName"enginemodulebase" "enginemodulebase"
33
34// constructor
35TEngineModuleBase::TEngineModuleBase()
36{
37 fCI = NULL__null;
38 fEngineName= ""; // none
39 fPrgVersion= 0;
40 fDebugFlags= 0;
41 fCIisStatic= false;
42} // TEngineModuleBase
43
44
45// destructor
46TEngineModuleBase::~TEngineModuleBase()
47{
48 #if defined SYSYNC_ENGINE || defined SYSYNC_ENGINE_TEST
49 if (fCI && !fCIisStatic) delete fCI;
50 #endif
51} // ~TEngineModuleBase
52
53
54
55// --- Initial connection ------------------------
56TSyError TEngineModuleBase::Connect( string aEngineName,
57 CVersion aPrgVersion,
58 uInt16 aDebugFlags)
59{
60 TSyError err= LOCERR_OK;
61
62 fEngineName = aEngineName;
63 fPrgVersion = aPrgVersion;
64 fDebugFlags = aDebugFlags;
65
66 #if defined SYSYNC_ENGINE || defined SYSYNC_ENGINE_TEST
67 uInt16 cbVersion= DB_Callback_Version; // use current by default
68 if (fCI==NULL__null) {
69 fCI = &fCIBuffer;
70 fCIisStatic = true;
71 }
72 else {
73 cbVersion= fCI->callbackVersion; // the cbVersion from outside (ConnectEngineS)
74 } // if
75
76 InitCallback_Exotic( fCI, cbVersion ); // be aware that it could be an older version
77 fCI->thisBase= this; // get <this> later for callback calls
78 CB_Connect ( fCI );
79 #endif
80
81 if (fPrgVersion==0) fPrgVersion= Plugin_Version( 0 ); // take the internal one
82 if (fPrgVersion<VP_UIApp) err= LOCERR_NOTIMP;
83
84 if (fCI) fCI->debugFlags= fDebugFlags;
85 if (!err) err= Init();
86 DEBUG_DB( fCI, MyName"enginemodulebase", "Connect","version=%08X flags=%04X err=%d", fPrgVersion, fDebugFlags, err );
87 return err;
88} // Connect
89
90
91TSyError TEngineModuleBase::Disconnect()
92{
93 if (!fCI) return LOCERR_OK;
94 DEBUG_DB( fCI, MyName"enginemodulebase", "Disconnect","" );
95
96 TSyError err= Term();
97 return err;
98} // Disconnect
99
100
101// ----------------------------------------------------------------------------------------------
102TSyError TEngineModuleBase::GetStrValue( KeyH aKeyH, cAppCharP aValName, string &aText )
103{
104 TSyError err;
105
106 const int txtFieldSize= 80; // a readonable string length to catch it at once
107 char txtField[ txtFieldSize ];
108 memSize txtSize;
109 char* f= (char*)&txtField;
110
111 // try directly to fit in a short string first
112 err= GetValue( aKeyH, aValName, VALTYPE_TEXT, f, txtFieldSize, txtSize );
113
114 bool tooShort= err==LOCERR_TRUNCATED;
115 if (tooShort) {
116 err= GetValue( aKeyH, aValName, VALTYPE_TEXT, f, 0, txtSize ); // get size
Value stored to 'err' is never read
117 f= (char*)malloc( txtSize+1 ); // plus NUL termination
118 err= GetValue( aKeyH, aValName, VALTYPE_TEXT, f, txtSize+1, txtSize ); // no error anymore
119 } // if
120
121 aText.assign(f, txtSize); // assign it
122
123 if (tooShort)
124 free( f ); // and deallocate again, if used dynamically
125
126 return err;
127} // GetStrValue;
128
129
130TSyError TEngineModuleBase::SetStrValue( KeyH aKeyH, cAppCharP aValName, string aText )
131{
132 // -1 automatically calculate length from null-terminated string
133 return SetValue( aKeyH, aValName, VALTYPE_TEXT, aText.c_str(), (memSize)-1 );
134} // SetStrValue
135
136
137// ----------------------------------------------------------------------------------------------
138TSyError TEngineModuleBase::GetInt8Value( KeyH aKeyH, cAppCharP aValName, sInt8 &aValue )
139{
140 memSize vSize;
141 return GetValue( aKeyH, aValName, VALTYPE_INT8, &aValue, sizeof(aValue), vSize );
142} // GetInt8Value
143
144TSyError TEngineModuleBase::GetInt8Value( KeyH aKeyH, cAppCharP aValName, uInt8 &aValue )
145{
146 memSize vSize;
147 return GetValue( aKeyH, aValName, VALTYPE_INT8, &aValue, sizeof(aValue), vSize );
148} // GetInt8Value
149
150TSyError TEngineModuleBase::SetInt8Value( KeyH aKeyH, cAppCharP aValName, uInt8 aValue )
151{
152 return SetValue( aKeyH, aValName, VALTYPE_INT8, &aValue, sizeof(aValue) );
153} // SetInt8Value
154
155
156// ----------------------------------------------------------------------------------------------
157TSyError TEngineModuleBase::GetInt16Value( KeyH aKeyH, cAppCharP aValName, sInt16 &aValue )
158{
159 memSize vSize;
160 return GetValue( aKeyH, aValName, VALTYPE_INT16, &aValue, sizeof(aValue), vSize );
161} // GetInt16Value
162
163TSyError TEngineModuleBase::GetInt16Value( KeyH aKeyH, cAppCharP aValName, uInt16 &aValue )
164{
165 memSize vSize;
166 return GetValue( aKeyH, aValName, VALTYPE_INT16, &aValue, sizeof(aValue), vSize );
167} // GetInt16Value
168
169TSyError TEngineModuleBase::SetInt16Value( KeyH aKeyH, cAppCharP aValName, uInt16 aValue )
170{
171 return SetValue( aKeyH, aValName, VALTYPE_INT16, &aValue, sizeof(aValue) );
172} // SetInt16Value
173
174
175// ----------------------------------------------------------------------------------------------
176TSyError TEngineModuleBase::GetInt32Value( KeyH aKeyH, cAppCharP aValName, sInt32 &aValue )
177{
178 memSize vSize;
179 return GetValue( aKeyH, aValName, VALTYPE_INT32, &aValue, sizeof(aValue), vSize );
180} // GetInt32Value
181
182TSyError TEngineModuleBase::GetInt32Value( KeyH aKeyH, cAppCharP aValName, uInt32 &aValue )
183{
184 memSize vSize;
185 return GetValue( aKeyH, aValName, VALTYPE_INT32, &aValue, sizeof(aValue), vSize );
186} // GetInt32Value
187
188TSyError TEngineModuleBase::SetInt32Value( KeyH aKeyH, cAppCharP aValName, uInt32 aValue )
189{
190 return SetValue( aKeyH, aValName, VALTYPE_INT32, &aValue, sizeof(aValue) );
191} // SetInt32Value
192
193
194// ----------------------------------------------------------------------------------------------
195void TEngineModuleBase::AppendSuffixToID( KeyH aKeyH, sInt32 &aID, cAppCharP aSuffix )
196{
197 string s= aSuffix;
198 if (s=="") return;
199 s= VALNAME_FLAG".FLAG" + s;
200 aID+= GetValueID( aKeyH, s.c_str() );
201} // AppendSuffixToID
202
203
204
205} // namespace sysync
206/* end of TEngineModuleBase implementation */
207
208#endif // not used in engine or engine with ENGINEINTERFACE_SUPPORT
209
210// eof