Commit 58c8344c authored by captainwong's avatar captainwong

fix vs2017 warnings

parent 6225f0bb
......@@ -33,12 +33,14 @@
class icmp_header
{
public:
enum { echo_reply = 0, destination_unreachable = 3, source_quench = 4,
enum {
echo_reply = 0, destination_unreachable = 3, source_quench = 4,
redirect = 5, echo_request = 8, time_exceeded = 11, parameter_problem = 12,
timestamp_request = 13, timestamp_reply = 14, info_request = 15,
info_reply = 16, address_request = 17, address_reply = 18 };
info_reply = 16, address_request = 17, address_reply = 18
};
icmp_header() { std::fill(rep_, rep_ + sizeof(rep_), 0); }
icmp_header() { memset(rep_, 0, sizeof(rep_)); }
unsigned char type() const { return rep_[0]; }
unsigned char code() const { return rep_[1]; }
......@@ -53,14 +55,20 @@ public:
void sequence_number(unsigned short n) { encode(6, 7, n); }
friend std::istream& operator>>(std::istream& is, icmp_header& header)
{ return is.read(reinterpret_cast<char*>(header.rep_), 8); }
{
return is.read(reinterpret_cast<char*>(header.rep_), 8);
}
friend std::ostream& operator<<(std::ostream& os, const icmp_header& header)
{ return os.write(reinterpret_cast<const char*>(header.rep_), 8); }
{
return os.write(reinterpret_cast<const char*>(header.rep_), 8);
}
private:
unsigned short decode(int a, int b) const
{ return ((rep_[a] << 8) + rep_[b]) & 0xFFFF; }
{
return ((rep_[a] << 8) + rep_[b]) & 0xFFFF;
}
void encode(int a, int b, unsigned short n)
{
......@@ -79,8 +87,7 @@ void compute_checksum(icmp_header& header,
+ header.identifier() + header.sequence_number();
Iterator body_iter = body_begin;
while (body_iter != body_end)
{
while (body_iter != body_end) {
sum += (static_cast<unsigned char>(*body_iter++) << 8);
if (body_iter != body_end)
sum += static_cast<unsigned char>(*body_iter++);
......
......@@ -51,7 +51,7 @@
class ipv4_header
{
public:
ipv4_header() { std::fill(rep_, rep_ + sizeof(rep_), 0); }
ipv4_header() { memset(rep_, 0, sizeof(rep_)); }
unsigned char version() const { return (rep_[0] >> 4) & 0xF; }
unsigned short header_length() const { return ((rep_[0] & 0xF) * 4) & 0xFFFF; }
......@@ -94,7 +94,9 @@ public:
private:
unsigned short decode(int a, int b) const
{ return ((rep_[a] << 8) + rep_[b]) & 0xFFFF; }
{
return ((rep_[a] << 8) + rep_[b]) & 0xFFFF;
}
unsigned char rep_[60];
};
......
......@@ -253,7 +253,7 @@ public:
num.ReleaseBuffer();
num.Format(_T("%03d"), nums);
tittle += num;
newFileName.Format(_T("%s%s"), tittle, ext);
newFileName.Format(_T("%s%s"), (LPCWSTR)tittle, (LPCWSTR)ext);
LPCTSTR szOldName = fileName.GetBuffer(fileName.GetLength());
fileName.ReleaseBuffer();
LPCTSTR szNewName = newFileName.GetBuffer(newFileName.GetLength());
......@@ -281,7 +281,7 @@ public:
filepath = find.GetFilePath();
if(DeleteFile(filepath.GetBuffer(filepath.GetLength()))){
CString trace;trace.Format(_T("CFileOper::DeleteFilesInFolder delete file %s \n"),
find.GetFilePath());
(LPCWSTR)find.GetFilePath());
TRACE(trace);
bfoundone = TRUE;
dwDeletedFileNums++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment