Skip to content

Cellular: Initialize CellularContext member variables in correct class #10557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions UNITTESTS/stubs/CellularContext_stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@

namespace mbed {

CellularContext::CellularContext() : _next(0), _stack(0), _pdp_type(DEFAULT_PDP_TYPE),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be inited in the same order as declared in header?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and they are what I can tell. Please tell which are not in correct order.

_authentication_type(CellularContext::CHAP), _connect_status(NSAPI_STATUS_DISCONNECTED), _status_cb(0),
_cid(-1), _new_context_set(false), _is_context_active(false), _is_context_activated(false),
_apn(0), _uname(0), _pwd(0), _dcd_pin(NC), _active_high(false), _cp_netif(0), _retry_array_length(0),
_retry_count(0), _device(0), _nw(0), _is_blocking(true)
{
memset(_retry_timeout_array, 0, CELLULAR_RETRY_ARRAY_SIZE);
}

void CellularContext::cp_data_received()
{
_cp_netif->data_received();
Expand Down
1 change: 1 addition & 0 deletions features/cellular/framework/API/CellularContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class CellularContext : public CellularInterface {
protected:
// friend of CellularDevice, so it's the only way to close or delete this class.
friend class CellularDevice;
CellularContext();
virtual ~CellularContext() {}
public: // from NetworkInterface
virtual nsapi_error_t set_blocking(bool blocking) = 0;
Expand Down
20 changes: 0 additions & 20 deletions features/cellular/framework/AT/AT_CellularContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,8 @@ AT_CellularContext::AT_CellularContext(ATHandler &at, CellularDevice *device, co
_nonip_req(nonip_req), _cp_in_use(false)
{
tr_info("New CellularContext %s (%p)", apn ? apn : "", this);
_stack = NULL;
_pdp_type = DEFAULT_PDP_TYPE;
_authentication_type = CellularContext::CHAP;
_connect_status = NSAPI_STATUS_DISCONNECTED;
_is_context_active = false;
_is_context_activated = false;
_apn = apn;
_uname = NULL;
_pwd = NULL;
_status_cb = NULL;
_cid = -1;
_new_context_set = false;
_next = NULL;
_dcd_pin = NC;
_active_high = false;
_cp_netif = NULL;
memset(_retry_timeout_array, 0, CELLULAR_RETRY_ARRAY_SIZE);
_retry_array_length = 0;
_retry_count = 0;
_is_blocking = true;
_device = device;
_nw = NULL;
}

AT_CellularContext::~AT_CellularContext()
Expand Down
9 changes: 9 additions & 0 deletions features/cellular/framework/device/CellularContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ MBED_WEAK CellularContext *CellularContext::get_default_nonip_instance()
return context;
}

CellularContext::CellularContext() : _next(0), _stack(0), _pdp_type(DEFAULT_PDP_TYPE),
_authentication_type(CellularContext::CHAP), _connect_status(NSAPI_STATUS_DISCONNECTED), _status_cb(0),
_cid(-1), _new_context_set(false), _is_context_active(false), _is_context_activated(false),
_apn(0), _uname(0), _pwd(0), _dcd_pin(NC), _active_high(false), _cp_netif(0), _retry_array_length(0),
_retry_count(0), _device(0), _nw(0), _is_blocking(true)
{
memset(_retry_timeout_array, 0, CELLULAR_RETRY_ARRAY_SIZE);
}

void CellularContext::cp_data_received()
{
_cp_netif->data_received();
Expand Down