Skip to content

Commit f55b929

Browse files
author
deepikabhavnani
committed
ATCmdParser: Added namespace std for va_list
1 parent 3d5ec66 commit f55b929

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

platform/ATCmdParser.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
#include "ATCmdParser.h"
2222
#include "mbed_poll.h"
2323
#include "mbed_debug.h"
24+
#include <stdio.h>
25+
#include <stdlib.h>
26+
#include <string.h>
2427

2528
#ifdef LF
2629
#undef LF
@@ -102,7 +105,7 @@ int ATCmdParser::read(char *data, int size)
102105

103106

104107
// printf/scanf handling
105-
int ATCmdParser::vprintf(const char *format, va_list args)
108+
int ATCmdParser::vprintf(const char *format, std::va_list args)
106109
{
107110

108111
if (vsprintf(_buffer, format, args) < 0) {
@@ -118,7 +121,7 @@ int ATCmdParser::vprintf(const char *format, va_list args)
118121
return i;
119122
}
120123

121-
int ATCmdParser::vscanf(const char *format, va_list args)
124+
int ATCmdParser::vscanf(const char *format, std::va_list args)
122125
{
123126
// Since format is const, we need to copy it into our buffer to
124127
// add the line's null terminator and clobber value-matches with asterisks.
@@ -181,7 +184,7 @@ int ATCmdParser::vscanf(const char *format, va_list args)
181184

182185

183186
// Command parsing with line handling
184-
bool ATCmdParser::vsend(const char *command, va_list args)
187+
bool ATCmdParser::vsend(const char *command, std::va_list args)
185188
{
186189
// Create and send command
187190
if (vsprintf(_buffer, command, args) < 0) {
@@ -205,7 +208,7 @@ bool ATCmdParser::vsend(const char *command, va_list args)
205208
return true;
206209
}
207210

208-
bool ATCmdParser::vrecv(const char *response, va_list args)
211+
bool ATCmdParser::vrecv(const char *response, std::va_list args)
209212
{
210213
restart:
211214
_aborted = false;
@@ -331,7 +334,7 @@ bool ATCmdParser::vrecv(const char *response, va_list args)
331334
// Mapping to vararg functions
332335
int ATCmdParser::printf(const char *format, ...)
333336
{
334-
va_list args;
337+
std::va_list args;
335338
va_start(args, format);
336339
int res = vprintf(format, args);
337340
va_end(args);
@@ -340,7 +343,7 @@ int ATCmdParser::printf(const char *format, ...)
340343

341344
int ATCmdParser::scanf(const char *format, ...)
342345
{
343-
va_list args;
346+
std::va_list args;
344347
va_start(args, format);
345348
int res = vscanf(format, args);
346349
va_end(args);
@@ -349,7 +352,7 @@ int ATCmdParser::scanf(const char *format, ...)
349352

350353
bool ATCmdParser::send(const char *command, ...)
351354
{
352-
va_list args;
355+
std::va_list args;
353356
va_start(args, command);
354357
bool res = vsend(command, args);
355358
va_end(args);
@@ -358,7 +361,7 @@ bool ATCmdParser::send(const char *command, ...)
358361

359362
bool ATCmdParser::recv(const char *response, ...)
360363
{
361-
va_list args;
364+
std::va_list args;
362365
va_start(args, response);
363366
bool res = vrecv(response, args);
364367
va_end(args);

platform/ATCmdParser.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class ATCmdParser : private NonCopyable<ATCmdParser> {
202202
*/
203203
bool send(const char *command, ...) MBED_PRINTF_METHOD(1, 2);
204204

205-
bool vsend(const char *command, va_list args);
205+
bool vsend(const char *command, std::va_list args);
206206

207207
/**
208208
* Receive an AT response
@@ -220,7 +220,7 @@ class ATCmdParser : private NonCopyable<ATCmdParser> {
220220
*/
221221
bool recv(const char *response, ...) MBED_SCANF_METHOD(1, 2);
222222

223-
bool vrecv(const char *response, va_list args);
223+
bool vrecv(const char *response, std::va_list args);
224224

225225
/**
226226
* Write a single byte to the underlying stream
@@ -265,7 +265,7 @@ class ATCmdParser : private NonCopyable<ATCmdParser> {
265265
*/
266266
int printf(const char *format, ...) MBED_PRINTF_METHOD(1, 2);
267267

268-
int vprintf(const char *format, va_list args);
268+
int vprintf(const char *format, std::va_list args);
269269

270270
/**
271271
* Direct scanf on underlying stream
@@ -277,7 +277,7 @@ class ATCmdParser : private NonCopyable<ATCmdParser> {
277277
*/
278278
int scanf(const char *format, ...) MBED_SCANF_METHOD(1, 2);
279279

280-
int vscanf(const char *format, va_list args);
280+
int vscanf(const char *format, std::va_list args);
281281

282282
/**
283283
* Attach a callback for out-of-band data

0 commit comments

Comments
 (0)