Skip to content

Commit 034637b

Browse files
author
Wang DeYou
committed
Eliminate some compilation warnings.
1. Remove "pragma once" in cpp source file 2. Remove unused variables 3. Uninitialized variable initialization 4. Match the data types on both sides of the relational operator
1 parent 45431f1 commit 034637b

File tree

6 files changed

+6
-10
lines changed

6 files changed

+6
-10
lines changed

sdk/src/arch/linux/net_socket.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ class _single_thread StreamSocketImpl : public StreamSocket
435435
virtual u_result send(const void * buffer, size_t len)
436436
{
437437
size_t ans = ::send( _socket_fd, buffer, len, MSG_NOSIGNAL);
438-
if (ans == (int)len) {
438+
if (ans == len) {
439439
return RESULT_OK;
440440
} else {
441441
switch (errno) {
@@ -719,7 +719,7 @@ class _single_thread DGramSocketImpl : public DGramSocket
719719

720720
virtual u_result sendTo(const SocketAddress & target, const void * buffer, size_t len)
721721
{
722-
const struct sockaddr* addr = &target ? reinterpret_cast<const struct sockaddr*>(target.getPlatformData()) : NULL;
722+
const struct sockaddr* addr = reinterpret_cast<const struct sockaddr*>(target.getPlatformData());
723723
assert(addr);
724724
size_t ans = ::sendto( _socket_fd, buffer, len, 0, addr, sizeof(sockaddr_storage));
725725
if (ans != (size_t)-1) {

sdk/src/sl_crc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ namespace sl {namespace crc32 {
7474
sl_u8 index;
7575
sl_u8* pch;
7676
pch = (unsigned char*)input;
77-
sl_u8 leftBytes = 4 - len & 0x3;
77+
sl_u8 leftBytes = (4 - len) & 0x3;
7878

7979
for (i = 0; i < len; i++) {
8080
index = (unsigned char)(crc^*pch);

sdk/src/sl_lidar_driver.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ namespace sl {
446446
}
447447

448448
//get scan answer type to specify how to wait data
449-
sl_u8 scanAnsType;
449+
sl_u8 scanAnsType = 0;
450450
if (ifSupportLidarConf) {
451451
getScanModeAnsType(scanAnsType, scanMode);
452452
}
@@ -1068,7 +1068,6 @@ namespace sl {
10681068

10691069
sl_result _sendCommand(sl_u16 cmd, const void * payload = NULL, size_t payloadsize = 0 )
10701070
{
1071-
sl_u8 pkt_header[10];
10721071
sl_u8 checksum = 0;
10731072

10741073
std::vector<sl_u8> cmd_packet;
@@ -1099,7 +1098,7 @@ namespace sl {
10991098

11001099
}
11011100
sl_u8 packet[1024];
1102-
for (int pos = 0; pos < cmd_packet.size(); pos++) {
1101+
for (sl_u32 pos = 0; pos < cmd_packet.size(); pos++) {
11031102
packet[pos] = cmd_packet[pos];
11041103
}
11051104
_channel->write(packet, cmd_packet.size());
@@ -1355,7 +1354,7 @@ namespace sl {
13551354

13561355
int dist_major2;
13571356

1358-
sl_u32 scalelvl1, scalelvl2;
1357+
sl_u32 scalelvl1 = 0, scalelvl2 = 0;
13591358

13601359
// prefetch next ...
13611360
if (pos == _countof(_cached_previous_ultracapsuledata.ultra_cabins) - 1) {

sdk/src/sl_serial_channel.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
*
3131
*/
3232

33-
#pragma once
3433
#include "sl_lidar_driver.h"
3534
#include "hal/abs_rxtx.h"
3635
#include "hal/socket.h"

sdk/src/sl_tcp_channel.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
*
3131
*/
3232

33-
#pragma once
3433
#include "sl_lidar_driver.h"
3534
#include "hal/abs_rxtx.h"
3635
#include "hal/socket.h"

sdk/src/sl_udp_channel.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
*
3131
*/
3232

33-
#pragma once
3433
#include "sl_lidar_driver.h"
3534
#include "hal/abs_rxtx.h"
3635
#include "hal/socket.h"

0 commit comments

Comments
 (0)