Skip to content

Commit

Permalink
fix incorrect formatting #1288 this time in the right branch...
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreRouma committed Jan 22, 2024
1 parent 3e58d4b commit 691216a
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "spectran_http_client.h"
#include <utils/flog.h>
#include <inttypes.h>

SpectranHTTPClient::SpectranHTTPClient(std::string host, int port, dsp::stream<dsp::complex_t>* stream) {
this->stream = stream;
Expand Down Expand Up @@ -50,10 +51,10 @@ void SpectranHTTPClient::setCenterFrequency(uint64_t freq) {
// Make request
net::http::RequestHeader rqhdr(net::http::METHOD_PUT, "/control", host);
char buf[1024];
sprintf(buf, "{\"frequencyCenter\":%d,\"frequencySpan\":%d,\"type\":\"capture\"}", freq, _samplerate);
sprintf(buf, "{\"frequencyCenter\":%" PRIu64 ",\"frequencySpan\":%" PRIu64 ",\"type\":\"capture\"}", freq, _samplerate);
std::string data = buf;
char lenBuf[16];
sprintf(lenBuf, "%d", data.size());
sprintf(lenBuf, "%" PRIu64, data.size());

This comment has been minimized.

Copy link
@hzeller

hzeller Jan 22, 2024

Contributor

size_t might not be 64 bit on all platforms (e.g. on 32 bit platforms). So I'd recommend casting it to uint64_t to make sure it will match the 64-bit formatting specifier.

This comment has been minimized.

Copy link
@AlexandreRouma

AlexandreRouma Jan 22, 2024

Author Owner

I probably shouldn't be coding while distracted

rqhdr.setField("Content-Length", lenBuf);
controlHttp.sendRequestHeader(rqhdr);
controlSock->sendstr(data);
Expand Down

0 comments on commit 691216a

Please sign in to comment.