Skip to content

Commit fd6f79c

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

File tree

5 files changed

+32
-23
lines changed

5 files changed

+32
-23
lines changed

server/gdial-rest.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include <stdio.h>
2323
#include <netinet/in.h>
2424
#include <sys/socket.h>
25+
#include <stdint.h>
26+
#include <inttypes.h>
2527

2628
#include <glib.h>
2729
#include <libsoup/soup.h>
@@ -159,7 +161,7 @@ static GList *gdial_rest_server_registered_apps_clear(GDialRestServer *self, GLi
159161
GDialRestServerPrivate *priv = gdial_rest_server_get_instance_private(self);
160162
GDialAppRegistry *app_registry = (GDialAppRegistry *)found->data;
161163
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);
164+
GDIAL_LOGINFO("gdial_local_rest_http_server_callback handler Removed for App[%s]instance[%x]", app_registry->name,(uintptr_t)priv->local_soup_instance);
163165
soup_server_remove_handler(priv->local_soup_instance, app_registry->app_uri);
164166
gdial_app_regstry_dispose (app_registry);
165167
g_list_free(found);
@@ -712,7 +714,10 @@ static void gdial_local_rest_http_server_callback(SoupServer *server,
712714
continue;
713715
}
714716
if (j == 0) {
715-
g_strlcpy(base, elements[i], sizeof(base));
717+
ret = g_strlcpy(base, elements[i], sizeof(base));
718+
if (ret >= sizeof(base)) {
719+
GDIAL_LOGERROR("Warn: base too long");
720+
}
716721
}
717722
else if (j == 1) {
718723
ret = g_strlcpy(instance, elements[i], sizeof(instance));
@@ -1165,7 +1170,7 @@ gboolean gdial_rest_server_register_app(GDialRestServer *self, const gchar *app_
11651170

11661171
if( 0 != strcmp(app_name,"system"))
11671172
{
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);
1173+
GDIAL_LOGINFO("gdial_local_rest_http_server_callback handler added for App[%s]uri[%s]instance[%x]",app_name,app_registry->app_uri,(uintptr_t)priv->local_soup_instance);
11691174
soup_server_add_handler(priv->local_soup_instance, app_registry->app_uri, gdial_local_rest_http_server_callback, self, NULL);
11701175
}
11711176
GDIAL_LOGTRACE("Exiting ...");
@@ -1197,7 +1202,7 @@ gboolean gdial_rest_server_register_app_registry(GDialRestServer *self, GDialApp
11971202
g_return_val_if_fail(gdial_rest_server_is_app_registered(self, app_registry->name), FALSE);
11981203
if( 0 != strcmp(app_registry->name,"system"))
11991204
{
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);
1205+
GDIAL_LOGINFO("gdial_local_rest_http_server_callback handler added for App[%s]uri[%s]instance[%x]",app_registry->name,app_registry->app_uri,(uintptr_t)priv->local_soup_instance);
12011206
soup_server_add_handler(priv->local_soup_instance, app_registry->app_uri, gdial_local_rest_http_server_callback, self, NULL);
12021207
}
12031208
return TRUE;
@@ -1360,4 +1365,4 @@ GDIAL_STATIC_INLINE void GET_APP_response_builder_destroy(void *builder) {
13601365
g_free(rbuilder->additionalData);
13611366

13621367
g_free(builder);
1363-
}
1368+
}

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,4 @@ void gdial_plat_util_log(gdial_plat_util_LogLevel level,
128128
func,
129129
formatted);
130130
fflush(stderr);
131-
}
131+
}

server/plat/gdial.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ class GDialCastObject
8282
reterror = GDIAL_CAST_ERROR_NONE;
8383
}
8484
}
85+
else
86+
{
87+
delete AppObj; // fix RESOURCE_LEAK coverity
88+
}
8589
GDIAL_LOGTRACE("Exiting ...");
8690
return reterror;
8791
}
@@ -239,7 +243,7 @@ class GDialCastObject
239243
GDIAL_LOGINFO("App[%s] param[%s] observer[%p]",applicationName.c_str(),parameter.c_str(),m_observer);
240244
if (nullptr!=m_observer)
241245
{
242-
m_observer->onApplicationLaunchRequest(applicationName,parameter);
246+
m_observer->onApplicationLaunchRequest(std::move(applicationName),std::move(parameter));
243247
}
244248
GDIAL_LOGTRACE("Exiting ...");
245249
return GDIAL_CAST_ERROR_NONE;
@@ -274,10 +278,10 @@ class GDialCastObject
274278
m_observer);
275279
if (nullptr!=m_observer)
276280
{
277-
m_observer->onApplicationLaunchRequestWithLaunchParam( applicationName,
278-
payLoad,
279-
queryString,
280-
additionalDataUrl );
281+
m_observer->onApplicationLaunchRequestWithLaunchParam( std::move(applicationName),
282+
std::move(payLoad),
283+
std::move(queryString),
284+
std::move(additionalDataUrl) );
281285
}
282286
GDIAL_LOGTRACE("Exiting ...");
283287
return GDIAL_CAST_ERROR_NONE;
@@ -298,7 +302,7 @@ class GDialCastObject
298302
GDIAL_LOGINFO("App[%s]ID[%s]observer[%p]",applicationName.c_str(),applicationId.c_str(),m_observer);
299303
if (nullptr!=m_observer)
300304
{
301-
m_observer->onApplicationHideRequest(applicationName,applicationId);
305+
m_observer->onApplicationHideRequest(std::move(applicationName),std::move(applicationId));
302306
}
303307
GDIAL_LOGTRACE("Exiting ...");
304308
return GDIAL_CAST_ERROR_NONE;
@@ -320,7 +324,7 @@ class GDialCastObject
320324
GDIAL_LOGINFO("App[%s]ID[%s]observer[%p]",applicationName.c_str(),applicationId.c_str(),m_observer);
321325
if (nullptr!=m_observer)
322326
{
323-
m_observer->onApplicationResumeRequest(applicationName,applicationId);
327+
m_observer->onApplicationResumeRequest(std::move(applicationName),std::move(applicationId));
324328
}
325329
GDIAL_LOGTRACE("Exiting ...");
326330
return GDIAL_CAST_ERROR_NONE;
@@ -342,7 +346,7 @@ class GDialCastObject
342346
GDIAL_LOGINFO("App[%s]ID[%s]observer[%p]",applicationName.c_str(),applicationId.c_str(),m_observer);
343347
if (nullptr!=m_observer)
344348
{
345-
m_observer->onApplicationStopRequest(applicationName,applicationId);
349+
m_observer->onApplicationStopRequest(std::move(applicationName),std::move(applicationId));
346350
}
347351
GDIAL_LOGTRACE("Exiting ...");
348352
return GDIAL_CAST_ERROR_NONE;
@@ -364,7 +368,7 @@ class GDialCastObject
364368
GDIAL_LOGINFO("App[%s]ID[%s]observer[%p]",applicationName.c_str(),applicationId.c_str(),m_observer);
365369
if (nullptr!=m_observer)
366370
{
367-
m_observer->onApplicationStateRequest(applicationName,applicationId);
371+
m_observer->onApplicationStateRequest(std::move(applicationName),std::move(applicationId));
368372
}
369373
GDIAL_LOGTRACE("Exiting ...");
370374
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)