Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[mms-engine] Replaced MMS_CAST with G_CAST. MER#1027
  • Loading branch information
monich committed Sep 29, 2016
1 parent e3f703c commit 9b4a924
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 15 deletions.
3 changes: 2 additions & 1 deletion mms-engine/mms_engine.c
Expand Up @@ -31,6 +31,7 @@
/* Generated code */
#include "org.nemomobile.MmsEngine.h"

#include <gutil_macros.h>
#include <gutil_misc.h>
#include <gutil_log.h>

Expand Down Expand Up @@ -76,7 +77,7 @@ G_DEFINE_TYPE(MMSEngine, mms_engine, G_TYPE_OBJECT)

inline static MMSEngine*
mms_engine_from_dispatcher_delegate(MMSDispatcherDelegate* delegate)
{ return MMS_CAST(delegate,MMSEngine,dispatcher_delegate); }
{ return G_CAST(delegate,MMSEngine,dispatcher_delegate); }

static
gboolean
Expand Down
5 changes: 0 additions & 5 deletions mms-lib/include/mms_lib_types.h
Expand Up @@ -10,7 +10,6 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/

#ifndef JOLLA_MMS_LIB_TYPES_H
Expand Down Expand Up @@ -82,10 +81,6 @@ typedef enum _MMS_CONNECTION_TYPE {
MMS_CONNECTION_TYPE_USER /* Connection requested by user */
} MMS_CONNECTION_TYPE;

/* Convenience macros */
#define MMS_CAST(address,type,field) \
((type *)((guint8*)(address) - G_STRUCT_OFFSET(type,field)))

#endif /* JOLLA_MMS_LIB_TYPES_H */

/*
Expand Down
4 changes: 3 additions & 1 deletion mms-lib/src/mms_attachment_jpeg.c
Expand Up @@ -15,6 +15,8 @@
#include "mms_attachment_image.h"
#include "mms_file_util.h"

#include <gutil_macros.h>

#include <jpeglib.h>
#include <jerror.h>
#include <setjmp.h>
Expand Down Expand Up @@ -47,7 +49,7 @@ typedef struct mms_attachment_jpeg_resize {

static inline MMSAttachmentJpegResize*
mms_attachment_jpeg_resize_cast(MMSAttachmentImageResize* resize)
{ return MMS_CAST(resize, MMSAttachmentJpegResize, pub); }
{ return G_CAST(resize, MMSAttachmentJpegResize, pub); }

static
void
Expand Down
4 changes: 3 additions & 1 deletion mms-lib/src/mms_dispatcher.c
Expand Up @@ -23,6 +23,8 @@
#include "mms_util.h"
#include "mms_task.h"

#include <gutil_macros.h>

#include <errno.h>

/* Logging */
Expand Down Expand Up @@ -57,7 +59,7 @@ typedef struct mms_dispatcher_idle_callback {

inline static MMSDispatcher*
mms_dispatcher_from_task_delegate(MMSTaskDelegate* delegate)
{ return MMS_CAST(delegate,MMSDispatcher,task_delegate); }
{ return G_CAST(delegate,MMSDispatcher,task_delegate); }

static
void
Expand Down
6 changes: 4 additions & 2 deletions mms-lib/test/common/test_handler.c
Expand Up @@ -15,6 +15,8 @@
#include "test_handler.h"
#include "mms_dispatcher.h"

#include <gutil_macros.h>

/* Logging */
#define GLOG_MODULE_NAME mms_handler_log
#include <gutil_log.h>
Expand Down Expand Up @@ -104,15 +106,15 @@ MMSHandlerRecordSend*
mms_handler_test_record_send(MMSHandlerRecord* rec)
{
GASSERT(rec->type == MMS_HANDLER_RECORD_SEND);
return MMS_CAST(rec, MMSHandlerRecordSend, rec);
return G_CAST(rec, MMSHandlerRecordSend, rec);
}

static inline
MMSHandlerRecordReceive*
mms_handler_test_record_receive(MMSHandlerRecord* rec)
{
GASSERT(rec->type == MMS_HANDLER_RECORD_RECEIVE);
return MMS_CAST(rec, MMSHandlerRecordReceive, rec);
return G_CAST(rec, MMSHandlerRecordReceive, rec);
}

static
Expand Down
3 changes: 2 additions & 1 deletion mms-lib/test/test_read_report/test_read_report.c
Expand Up @@ -23,6 +23,7 @@
#include "mms_settings.h"
#include "mms_dispatcher.h"

#include <gutil_macros.h>
#include <gutil_log.h>

#include <gio/gio.h>
Expand Down Expand Up @@ -80,7 +81,7 @@ test_done(
MMSDispatcherDelegate* delegate,
MMSDispatcher* dispatcher)
{
Test* test = MMS_CAST(delegate,Test,delegate);
Test* test = G_CAST(delegate,Test,delegate);
const TestDesc* desc = test->desc;
const char* name = desc->name;
if (test->ret == RET_OK) {
Expand Down
3 changes: 2 additions & 1 deletion mms-lib/test/test_retrieve/test_retrieve.c
Expand Up @@ -25,6 +25,7 @@
#include "mms_settings.h"
#include "mms_dispatcher.h"

#include <gutil_macros.h>
#include <gutil_log.h>
#include <libsoup/soup-status.h>

Expand Down Expand Up @@ -513,7 +514,7 @@ test_done(
MMSDispatcherDelegate* delegate,
MMSDispatcher* dispatcher)
{
Test* test = MMS_CAST(delegate,Test,delegate);
Test* test = G_CAST(delegate,Test,delegate);
if (!mms_handler_test_receive_pending(test->handler, NULL)) {
test_finish(test);
}
Expand Down
3 changes: 2 additions & 1 deletion mms-lib/test/test_retrieve_no_proxy/test_retrieve_no_proxy.c
Expand Up @@ -24,6 +24,7 @@
#include "mms_settings.h"
#include "mms_dispatcher.h"

#include <gutil_macros.h>
#include <gutil_log.h>
#include <gio/gio.h>
#include <libsoup/soup-status.h>
Expand Down Expand Up @@ -95,7 +96,7 @@ test_done(
MMSDispatcherDelegate* delegate,
MMSDispatcher* dispatcher)
{
Test* test = MMS_CAST(delegate,Test,delegate);
Test* test = G_CAST(delegate,Test,delegate);
test_finish(test);
}

Expand Down
3 changes: 2 additions & 1 deletion mms-lib/test/test_retrieve_order/test_retrieve_order.c
Expand Up @@ -24,6 +24,7 @@
#include "mms_settings.h"
#include "mms_dispatcher.h"

#include <gutil_macros.h>
#include <gutil_log.h>
#include <libsoup/soup-status.h>

Expand Down Expand Up @@ -152,7 +153,7 @@ test_done(
MMSDispatcherDelegate* delegate,
MMSDispatcher* dispatcher)
{
Test* test = MMS_CAST(delegate,Test,delegate);
Test* test = G_CAST(delegate,Test,delegate);
if (!mms_handler_test_receive_pending(test->handler, NULL)) {
test_finish(test);
}
Expand Down
3 changes: 2 additions & 1 deletion mms-lib/test/test_send/test_send.c
Expand Up @@ -24,6 +24,7 @@
#include "mms_settings.h"
#include "mms_dispatcher.h"

#include <gutil_macros.h>
#include <gutil_log.h>
#include <gio/gio.h>
#include <libsoup/soup-status.h>
Expand Down Expand Up @@ -315,7 +316,7 @@ test_done(
MMSDispatcherDelegate* delegate,
MMSDispatcher* dispatcher)
{
Test* test = MMS_CAST(delegate,Test,delegate);
Test* test = G_CAST(delegate,Test,delegate);
if (!mms_handler_test_receive_pending(test->handler, NULL)) {
test_finish(test);
}
Expand Down

0 comments on commit 9b4a924

Please sign in to comment.