get rid of more -Wconversion warnings
parent
f7fee036c1
commit
4a04c40595
@ -1,22 +1,7 @@
|
||||
#include <buffer.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#ifdef __MINGW32__
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
void buffer_close(buffer* b) {
|
||||
if (b->fd != -1) close(b->fd);
|
||||
switch (b->todo) {
|
||||
case FREE: free(b->x); break;
|
||||
case MUNMAP:
|
||||
#ifdef __MINGW32__
|
||||
UnmapViewOfFile(b->x);
|
||||
#else
|
||||
munmap(b->x,b->a); break;
|
||||
#endif
|
||||
default: ;
|
||||
}
|
||||
if (b->deinit) b->deinit(b);
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
#include "buffer.h"
|
||||
|
||||
extern int buffer_stubborn_read(ssize_t (*op)(),int fd,const char* buf, size_t len,void* cookie);
|
||||
extern ssize_t buffer_stubborn_read(ssize_t (*op)(),int fd,const char* buf, size_t len,void* cookie);
|
||||
|
||||
int buffer_feed(buffer* b) {
|
||||
ssize_t buffer_feed(buffer* b) {
|
||||
if (b->p==b->n) {
|
||||
int w;
|
||||
ssize_t w;
|
||||
if ((w=buffer_stubborn_read(b->op,b->fd,b->x,b->a,b))<0)
|
||||
return -1;
|
||||
b->n=w;
|
||||
b->n=(size_t)w;
|
||||
b->p=0;
|
||||
}
|
||||
return (b->n-b->p);
|
||||
return (ssize_t)(b->n-b->p);
|
||||
}
|
||||
|
@ -1,10 +1,13 @@
|
||||
#include "buffer.h"
|
||||
|
||||
extern int buffer_stubborn(ssize_t (*op)(),int fd,const char* buf, size_t len,void* cookie);
|
||||
extern ssize_t buffer_stubborn(ssize_t (*op)(),int fd,const char* buf, size_t len,void* cookie);
|
||||
|
||||
extern int buffer_flush(buffer* b) {
|
||||
register int p;
|
||||
register size_t p;
|
||||
register ssize_t r;
|
||||
if (!(p=b->p)) return 0; /* buffer already empty */
|
||||
b->p=0;
|
||||
return buffer_stubborn(b->op,b->fd,b->x,p,b);
|
||||
r=buffer_stubborn(b->op,b->fd,b->x,p,b);
|
||||
if (r>0) r=0;
|
||||
return (int)r;
|
||||
}
|
||||
|
@ -0,0 +1,6 @@
|
||||
#include <stdlib.h>
|
||||
#include "buffer.h"
|
||||
|
||||
void buffer_free(void* buf) {
|
||||
free(buf);
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
#include "buffer.h"
|
||||
#ifdef __MINGW32__
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
void buffer_munmap(void* buf) {
|
||||
buffer* b=(buffer*)buf;
|
||||
#ifdef __MINGW32__
|
||||
UnmapViewOfFile(b->x);
|
||||
#else
|
||||
munmap(b->x,b->a);
|
||||
#endif
|
||||
}
|
@ -1,17 +1,14 @@
|
||||
#include "ip6.h"
|
||||
#include "haveinline.h"
|
||||
#include "fmt.h"
|
||||
|
||||
static inline char tohex(char c) {
|
||||
return c>=10?c-10+'a':c+'0';
|
||||
}
|
||||
|
||||
unsigned int fmt_ip6_flat(char *s,const char ip[16])
|
||||
size_t fmt_ip6_flat(char *s,const char ip[16])
|
||||
{
|
||||
int i;
|
||||
if (!s) return 32;
|
||||
for (i=0; i<16; i++) {
|
||||
*s++=tohex((unsigned char)ip[i] >> 4);
|
||||
*s++=tohex((unsigned char)ip[i] & 15);
|
||||
*s++=fmt_tohex((char)((unsigned char)ip[i] >> 4));
|
||||
*s++=fmt_tohex((unsigned char)ip[i] & 15);
|
||||
}
|
||||
return 32;
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
#include "scan.h"
|
||||
|
||||
unsigned int scan_ip6_flat(const char *s,char ip[16])
|
||||
size_t scan_ip6_flat(const char *s,char ip[16])
|
||||
{
|
||||
int i;
|
||||
size_t i;
|
||||
for (i=0; i<16; i++) {
|
||||
int tmp;
|
||||
tmp=scan_fromhex(*s++);
|
||||
tmp=scan_fromhex((unsigned char)*s++);
|
||||
if (tmp<0) return 0;
|
||||
ip[i]=tmp << 4;
|
||||
tmp=scan_fromhex(*s++);
|
||||
ip[i]=(char)(tmp << 4);
|
||||
tmp=scan_fromhex((unsigned char)*s++);
|
||||
if (tmp<0) return 0;
|
||||
ip[i]+=tmp;
|
||||
ip[i] = ip[i] | (char)tmp;
|
||||
}
|
||||
return 32;
|
||||
}
|
||||
|
Loading…
Reference in New Issue