@@ -75,23 +75,26 @@ static void init_to_sim_state()
75
75
static void test_information_interface ()
76
76
{
77
77
CellularInformation *info = cellular.get_device ()->open_information (&cellular_serial);
78
+ const int kbuf_size = 100 ;
79
+ char *buf = (char *)malloc (sizeof (char ) * kbuf_size);
78
80
79
- char buf[100 ];
80
- TEST_ASSERT (info->get_manufacturer (buf, 100 ) == NSAPI_ERROR_OK);
81
- TEST_ASSERT (info->get_model (buf, 100 ) == NSAPI_ERROR_OK);
82
- TEST_ASSERT (info->get_revision (buf, 100 ) == NSAPI_ERROR_OK);
83
- TEST_ASSERT (info->get_serial_number (buf, 100 , CellularInformation::SN) == NSAPI_ERROR_OK);
81
+ TEST_ASSERT (info->get_manufacturer (buf, kbuf_size) == NSAPI_ERROR_OK);
82
+ TEST_ASSERT (info->get_model (buf, kbuf_size) == NSAPI_ERROR_OK);
83
+ TEST_ASSERT (info->get_revision (buf, kbuf_size) == NSAPI_ERROR_OK);
84
+ TEST_ASSERT (info->get_serial_number (buf, kbuf_size, CellularInformation::SN) == NSAPI_ERROR_OK);
84
85
85
- nsapi_error_t err = info->get_serial_number (buf, 100 , CellularInformation::IMEI);
86
+ nsapi_error_t err = info->get_serial_number (buf, kbuf_size , CellularInformation::IMEI);
86
87
TEST_ASSERT (err == NSAPI_ERROR_UNSUPPORTED || err == NSAPI_ERROR_OK);
87
88
88
- err = info->get_serial_number (buf, 100 , CellularInformation::IMEISV);
89
+ err = info->get_serial_number (buf, kbuf_size , CellularInformation::IMEISV);
89
90
TEST_ASSERT (err == NSAPI_ERROR_UNSUPPORTED || err == NSAPI_ERROR_OK);
90
91
91
- err = info->get_serial_number (buf, 100 , CellularInformation::SVN);
92
+ err = info->get_serial_number (buf, kbuf_size , CellularInformation::SVN);
92
93
TEST_ASSERT (err == NSAPI_ERROR_UNSUPPORTED || err == NSAPI_ERROR_OK);
93
94
94
95
cellular.get_device ()->close_information ();
96
+
97
+ free (buf);
95
98
}
96
99
97
100
using namespace utest ::v1;
0 commit comments