Skip to content

Commit 87c3803

Browse files
committed
RDKEMW-6891: Coverity fix for xdial
1 parent 3202ca6 commit 87c3803

File tree

5 files changed

+27
-24
lines changed

5 files changed

+27
-24
lines changed

server/gdial-rest.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static GList *gdial_rest_server_registered_apps_clear(GDialRestServer *self, GLi
159159
GDialRestServerPrivate *priv = gdial_rest_server_get_instance_private(self);
160160
GDialAppRegistry *app_registry = (GDialAppRegistry *)found->data;
161161
registered_apps = g_list_remove_link(registered_apps, found);
162-
GDIAL_LOGINFO("gdial_local_rest_http_server_callback handler Removed for App[%s]instance[%x]", app_registry->name,priv->local_soup_instance);
162+
GDIAL_LOGINFO("gdial_local_rest_http_server_callback handler Removed for App[%s]instance[%x]", app_registry->name,(unsigned int)priv->local_soup_instance);
163163
soup_server_remove_handler(priv->local_soup_instance, app_registry->app_uri);
164164
gdial_app_regstry_dispose (app_registry);
165165
g_list_free(found);
@@ -712,7 +712,10 @@ static void gdial_local_rest_http_server_callback(SoupServer *server,
712712
continue;
713713
}
714714
if (j == 0) {
715-
g_strlcpy(base, elements[i], sizeof(base));
715+
ret = g_strlcpy(base, elements[i], sizeof(base));
716+
if (ret >= sizeof(base)) {
717+
GDIAL_LOGERROR("Warn: base too long");
718+
}
716719
}
717720
else if (j == 1) {
718721
ret = g_strlcpy(instance, elements[i], sizeof(instance));
@@ -1165,7 +1168,7 @@ gboolean gdial_rest_server_register_app(GDialRestServer *self, const gchar *app_
11651168

11661169
if( 0 != strcmp(app_name,"system"))
11671170
{
1168-
GDIAL_LOGINFO("gdial_local_rest_http_server_callback handler added for App[%s]uri[%s]instance[%x]",app_name,app_registry->app_uri,priv->local_soup_instance);
1171+
GDIAL_LOGINFO("gdial_local_rest_http_server_callback handler added for App[%s]uri[%s]instance[%x]",app_name,app_registry->app_uri,(unsigned int)priv->local_soup_instance);
11691172
soup_server_add_handler(priv->local_soup_instance, app_registry->app_uri, gdial_local_rest_http_server_callback, self, NULL);
11701173
}
11711174
GDIAL_LOGTRACE("Exiting ...");
@@ -1197,7 +1200,7 @@ gboolean gdial_rest_server_register_app_registry(GDialRestServer *self, GDialApp
11971200
g_return_val_if_fail(gdial_rest_server_is_app_registered(self, app_registry->name), FALSE);
11981201
if( 0 != strcmp(app_registry->name,"system"))
11991202
{
1200-
GDIAL_LOGINFO("gdial_local_rest_http_server_callback handler added for App[%s]uri[%s]instance[%x]",app_registry->name,app_registry->app_uri,priv->local_soup_instance);
1203+
GDIAL_LOGINFO("gdial_local_rest_http_server_callback handler added for App[%s]uri[%s]instance[%x]",app_registry->name,app_registry->app_uri,(unsigned int)priv->local_soup_instance);
12011204
soup_server_add_handler(priv->local_soup_instance, app_registry->app_uri, gdial_local_rest_http_server_callback, self, NULL);
12021205
}
12031206
return TRUE;
@@ -1360,4 +1363,4 @@ GDIAL_STATIC_INLINE void GET_APP_response_builder_destroy(void *builder) {
13601363
g_free(rbuilder->additionalData);
13611364

13621365
g_free(builder);
1363-
}
1366+
}

server/gdialserver_ut.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class gdialServiceTest: public GDialNotifier
4343
{
4444
GDIAL_LOGINFO("Entering ...");
4545
std::string activation = status ? "true" : "false";
46-
service->ActivationChanged(activation,"SampleTest");
46+
service->ActivationChanged(std::move(activation),"SampleTest");
4747
GDIAL_LOGINFO("Exiting ...");
4848
}
4949

@@ -137,9 +137,9 @@ class gdialServiceTest: public GDialNotifier
137137
break;
138138
}
139139

140-
appReq->Names = Names;
140+
appReq->Names = std::move(Names);
141141
appReq->prefixes = prefixes;
142-
appReq->cors = prefixes;
142+
appReq->cors = std::move(prefixes);
143143
appReq->allowStop = allowStop;
144144

145145
appReqList->pushBack(appReq);
@@ -253,4 +253,4 @@ int main(int argc, char *argv[])
253253
delete testObject;
254254

255255
return 0;
256-
}
256+
}

server/plat/gdial-plat-util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ void gdial_plat_util_log(gdial_plat_util_LogLevel level,
123123
fprintf(stderr, "[GDIAL][%d] %s [%s:%d] %s: %s \n",
124124
(int)syscall(SYS_gettid),
125125
levelMap[level],
126-
basename(file),
126+
basename(file).c_str(),
127127
line,
128128
func,
129129
formatted);
130130
fflush(stderr);
131-
}
131+
}

server/plat/gdial.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ class GDialCastObject
239239
GDIAL_LOGINFO("App[%s] param[%s] observer[%p]",applicationName.c_str(),parameter.c_str(),m_observer);
240240
if (nullptr!=m_observer)
241241
{
242-
m_observer->onApplicationLaunchRequest(applicationName,parameter);
242+
m_observer->onApplicationLaunchRequest(std::move(applicationName),std::move(parameter));
243243
}
244244
GDIAL_LOGTRACE("Exiting ...");
245245
return GDIAL_CAST_ERROR_NONE;
@@ -274,10 +274,10 @@ class GDialCastObject
274274
m_observer);
275275
if (nullptr!=m_observer)
276276
{
277-
m_observer->onApplicationLaunchRequestWithLaunchParam( applicationName,
278-
payLoad,
279-
queryString,
280-
additionalDataUrl );
277+
m_observer->onApplicationLaunchRequestWithLaunchParam( std::move(applicationName),
278+
std::move(payLoad),
279+
std::move(queryString),
280+
std::move(additionalDataUrl) );
281281
}
282282
GDIAL_LOGTRACE("Exiting ...");
283283
return GDIAL_CAST_ERROR_NONE;
@@ -298,7 +298,7 @@ class GDialCastObject
298298
GDIAL_LOGINFO("App[%s]ID[%s]observer[%p]",applicationName.c_str(),applicationId.c_str(),m_observer);
299299
if (nullptr!=m_observer)
300300
{
301-
m_observer->onApplicationHideRequest(applicationName,applicationId);
301+
m_observer->onApplicationHideRequest(std::move(applicationName),std::move(applicationId));
302302
}
303303
GDIAL_LOGTRACE("Exiting ...");
304304
return GDIAL_CAST_ERROR_NONE;
@@ -320,7 +320,7 @@ class GDialCastObject
320320
GDIAL_LOGINFO("App[%s]ID[%s]observer[%p]",applicationName.c_str(),applicationId.c_str(),m_observer);
321321
if (nullptr!=m_observer)
322322
{
323-
m_observer->onApplicationResumeRequest(applicationName,applicationId);
323+
m_observer->onApplicationResumeRequest(std::move(applicationName),std::move(applicationId));
324324
}
325325
GDIAL_LOGTRACE("Exiting ...");
326326
return GDIAL_CAST_ERROR_NONE;
@@ -342,7 +342,7 @@ class GDialCastObject
342342
GDIAL_LOGINFO("App[%s]ID[%s]observer[%p]",applicationName.c_str(),applicationId.c_str(),m_observer);
343343
if (nullptr!=m_observer)
344344
{
345-
m_observer->onApplicationStopRequest(applicationName,applicationId);
345+
m_observer->onApplicationStopRequest(std::move(applicationName),std::move(applicationId));
346346
}
347347
GDIAL_LOGTRACE("Exiting ...");
348348
return GDIAL_CAST_ERROR_NONE;
@@ -364,7 +364,7 @@ class GDialCastObject
364364
GDIAL_LOGINFO("App[%s]ID[%s]observer[%p]",applicationName.c_str(),applicationId.c_str(),m_observer);
365365
if (nullptr!=m_observer)
366366
{
367-
m_observer->onApplicationStateRequest(applicationName,applicationId);
367+
m_observer->onApplicationStateRequest(std::move(applicationName),std::move(applicationId));
368368
}
369369
GDIAL_LOGTRACE("Exiting ...");
370370
return GDIAL_CAST_ERROR_NONE;

server/plat/gdialappcache.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ void GDialAppStatusCache :: setAppCacheId(std::string app_name,std::string id)
4444
GDIAL_LOGTRACE("Entering ...");
4545
if(!strcmp(app_name.c_str(),"Netflix"))
4646
{
47-
GDialAppStatusCache::Netflix_AppCacheId = id;
47+
GDialAppStatusCache::Netflix_AppCacheId = std::move(id);
4848
GDIAL_LOGINFO("App cache Id of Netflix updated to %s",GDialAppStatusCache::Netflix_AppCacheId.c_str());
4949
}
5050
else if(!strcmp(app_name.c_str(),"YouTube"))
5151
{
52-
GDialAppStatusCache::Youtube_AppCacheId = id;
52+
GDialAppStatusCache::Youtube_AppCacheId = std::move(id);
5353
GDIAL_LOGINFO("App cache Id of Youtube updated to %s",GDialAppStatusCache::Youtube_AppCacheId.c_str());
5454
}
5555
else
@@ -75,7 +75,7 @@ AppCacheErrorCodes GDialAppStatusCache::UpdateAppStatusCache(AppInfo* appEntry)
7575
GDIAL_LOGINFO("erasing old data");
7676
err = ObjectCache->erase(id);
7777
}
78-
err = ObjectCache->insert(id,appEntry);
78+
err = ObjectCache->insert(std::move(id),appEntry);
7979
GDIAL_LOGTRACE("Exiting ...");
8080
return err;
8181
}
@@ -96,7 +96,7 @@ std::string GDialAppStatusCache::SearchAppStatusInCache(const char* app_name)
9696
appEntry->appId.c_str(),
9797
appEntry->appError.c_str());
9898
}
99-
GDIAL_LOGINFO("App State = ",state.c_str());
99+
GDIAL_LOGINFO("App State = %s ",state.c_str());
100100
GDIAL_LOGTRACE("Exiting ...");
101101
return state;
102102
}

0 commit comments

Comments
 (0)