mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-17 19:34:39 +01:00
Remove our usage of ssize_t
This commit is contained in:
1 parent
b87826698d
commit
51e2e7f8d5
7 files changed
+18
-27
No files matched your search
+2
-2
@@ -967,8 +967,8 @@ static u32 npdrmRead(FileNode *f, u8 *data, int size) {
|
||||
block = pgd->file_offset/pgd->block_size;
|
||||
offset = pgd->file_offset%pgd->block_size;
|
||||
|
||||
if (size > pgd->data_size)
|
||||
size = pgd->data_size;
|
||||
if (size > (int)pgd->data_size)
|
||||
size = (int)pgd->data_size;
|
||||
remain_size = size;
|
||||
|
||||
while(remain_size){
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
typedef intptr_t ssize_t;
|
||||
|
||||
#include <tchar.h>
|
||||
|
||||
#endif // _WIN32
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
Buffer::Buffer() { }
|
||||
Buffer::~Buffer() { }
|
||||
|
||||
char *Buffer::Append(ssize_t length) {
|
||||
char *Buffer::Append(size_t length) {
|
||||
if (length > 0) {
|
||||
size_t old_size = data_.size();
|
||||
data_.resize(old_size + length);
|
||||
@@ -120,8 +120,8 @@ void Buffer::Printf(const char *fmt, ...) {
|
||||
char buffer[2048];
|
||||
va_list vl;
|
||||
va_start(vl, fmt);
|
||||
ssize_t retval = vsnprintf(buffer, sizeof(buffer), fmt, vl);
|
||||
if (retval >= (ssize_t)sizeof(buffer)) {
|
||||
size_t retval = vsnprintf(buffer, sizeof(buffer), fmt, vl);
|
||||
if ((int)retval >= (int)sizeof(buffer)) {
|
||||
// Output was truncated. TODO: Do something.
|
||||
ERROR_LOG(IO, "Buffer::Printf truncated output");
|
||||
}
|
||||
@@ -135,7 +135,7 @@ void Buffer::Printf(const char *fmt, ...) {
|
||||
|
||||
bool Buffer::Flush(int fd) {
|
||||
// Look into using send() directly.
|
||||
bool success = (ssize_t)data_.size() == fd_util::WriteLine(fd, &data_[0], data_.size());
|
||||
bool success = data_.size() == fd_util::WriteLine(fd, &data_[0], data_.size());
|
||||
if (success) {
|
||||
data_.resize(0);
|
||||
}
|
||||
|
||||
@@ -16,8 +16,7 @@ class Buffer {
|
||||
|
||||
// Write max [length] bytes to the returned pointer.
|
||||
// Any other operation on this Buffer invalidates the pointer.
|
||||
char *Append(ssize_t length);
|
||||
char *Append(size_t length) { return Append((ssize_t)length); }
|
||||
char *Append(size_t length);
|
||||
|
||||
// These work pretty much like you'd expect.
|
||||
void Append(const char *str); // str null-terminated. The null is not copied.
|
||||
|
||||
@@ -46,9 +46,6 @@ inline bool endsWithNoCase(const std::string &str, const std::string &what) {
|
||||
|
||||
void DataToHexString(const uint8_t *data, size_t size, std::string *output);
|
||||
void DataToHexString(const char* prefix, uint32_t startAddr, const uint8_t* data, size_t size, std::string* output);
|
||||
inline void StringToHexString(const std::string &data, std::string *output) {
|
||||
DataToHexString((uint8_t *)(&data[0]), data.size(), output);
|
||||
}
|
||||
|
||||
std::string StringFromFormat(const char* format, ...);
|
||||
std::string StringFromInt(int value);
|
||||
|
||||
@@ -25,12 +25,12 @@ namespace fd_util {
|
||||
// Slow as hell and should only be used for prototyping.
|
||||
// Reads from a socket, up to an '\n'. This means that if the line ends
|
||||
// with '\r', the '\r' will be returned.
|
||||
ssize_t ReadLine(int fd, char *vptr, size_t buf_size) {
|
||||
size_t ReadLine(int fd, char *vptr, size_t buf_size) {
|
||||
char *buffer = vptr;
|
||||
size_t n;
|
||||
for (n = 1; n < buf_size; n++) {
|
||||
char c;
|
||||
ssize_t rc;
|
||||
size_t rc;
|
||||
if ((rc = read(fd, &c, 1)) == 1) {
|
||||
*buffer++ = c;
|
||||
if (c == '\n')
|
||||
@@ -54,7 +54,7 @@ ssize_t ReadLine(int fd, char *vptr, size_t buf_size) {
|
||||
}
|
||||
|
||||
// Misnamed, it just writes raw data in a retry loop.
|
||||
ssize_t WriteLine(int fd, const char *vptr, size_t n) {
|
||||
size_t WriteLine(int fd, const char *vptr, size_t n) {
|
||||
const char *buffer = vptr;
|
||||
size_t nleft = n;
|
||||
|
||||
@@ -73,11 +73,11 @@ ssize_t WriteLine(int fd, const char *vptr, size_t n) {
|
||||
return n;
|
||||
}
|
||||
|
||||
ssize_t WriteLine(int fd, const char *buffer) {
|
||||
size_t WriteLine(int fd, const char *buffer) {
|
||||
return WriteLine(fd, buffer, strlen(buffer));
|
||||
}
|
||||
|
||||
ssize_t Write(int fd, const std::string &str) {
|
||||
size_t Write(int fd, const std::string &str) {
|
||||
return WriteLine(fd, str.c_str(), str.size());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#ifndef _FD_UTIL
|
||||
#define _FD_UTIL
|
||||
#pragma once
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
|
||||
#include "base/basictypes.h"
|
||||
@@ -9,12 +8,12 @@
|
||||
namespace fd_util {
|
||||
|
||||
// Slow as hell and should only be used for prototyping.
|
||||
ssize_t ReadLine(int fd, char *buffer, size_t buf_size);
|
||||
size_t ReadLine(int fd, char *buffer, size_t buf_size);
|
||||
|
||||
// Decently fast.
|
||||
ssize_t WriteLine(int fd, const char *buffer, size_t buf_size);
|
||||
ssize_t WriteLine(int fd, const char *buffer);
|
||||
ssize_t Write(int fd, const std::string &str);
|
||||
size_t WriteLine(int fd, const char *buffer, size_t buf_size);
|
||||
size_t WriteLine(int fd, const char *buffer);
|
||||
size_t Write(int fd, const std::string &str);
|
||||
|
||||
// Returns true if the fd became ready, false if it didn't or
|
||||
// if there was another error.
|
||||
@@ -25,5 +24,3 @@ void SetNonBlocking(int fd, bool non_blocking);
|
||||
std::string GetLocalIP(int sock);
|
||||
|
||||
} // fd_util
|
||||
|
||||
#endif // _FD_UTIL
|
||||
Reference in new issue
Block a user