Commit b82db8eb authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Update for weekly 23/6.

parent 00bf79b1
...@@ -155,8 +155,8 @@ func MyPID() string { ...@@ -155,8 +155,8 @@ func MyPID() string {
} }
// Thanks to Andrew Gerrand for this hack. // Thanks to Andrew Gerrand for this hack.
func asSlice(ptr unsafe.Pointer, byteCount int) []byte { func asSlice(ptr unsafe.Pointer, byteCount uintptr) []byte {
h := &reflect.SliceHeader{uintptr(ptr), byteCount, byteCount} h := &reflect.SliceHeader{uintptr(ptr), int(byteCount), int(byteCount)}
return *(*[]byte)(unsafe.Pointer(h)) return *(*[]byte)(unsafe.Pointer(h))
} }
......
...@@ -298,8 +298,8 @@ type castPointerFunc func(unsafe.Pointer) interface{} ...@@ -298,8 +298,8 @@ type castPointerFunc func(unsafe.Pointer) interface{}
type operationHandler struct { type operationHandler struct {
Name string Name string
Func operationFunc Func operationFunc
InputSize int InputSize uintptr
OutputSize int OutputSize uintptr
DecodeIn castPointerFunc DecodeIn castPointerFunc
DecodeOut castPointerFunc DecodeOut castPointerFunc
FileNames int FileNames int
...@@ -332,7 +332,7 @@ func init() { ...@@ -332,7 +332,7 @@ func init() {
operationHandlers[i] = &operationHandler{Name: "UNKNOWN"} operationHandlers[i] = &operationHandler{Name: "UNKNOWN"}
} }
for op, sz := range map[opcode]int{ for op, sz := range map[opcode]uintptr{
_OP_FORGET: unsafe.Sizeof(ForgetIn{}), _OP_FORGET: unsafe.Sizeof(ForgetIn{}),
_OP_GETATTR: unsafe.Sizeof(GetAttrIn{}), _OP_GETATTR: unsafe.Sizeof(GetAttrIn{}),
_OP_SETATTR: unsafe.Sizeof(SetAttrIn{}), _OP_SETATTR: unsafe.Sizeof(SetAttrIn{}),
...@@ -364,7 +364,7 @@ func init() { ...@@ -364,7 +364,7 @@ func init() {
operationHandlers[op].InputSize = sz operationHandlers[op].InputSize = sz
} }
for op, sz := range map[opcode]int{ for op, sz := range map[opcode]uintptr{
_OP_LOOKUP: unsafe.Sizeof(EntryOut{}), _OP_LOOKUP: unsafe.Sizeof(EntryOut{}),
_OP_GETATTR: unsafe.Sizeof(AttrOut{}), _OP_GETATTR: unsafe.Sizeof(AttrOut{}),
_OP_SETATTR: unsafe.Sizeof(AttrOut{}), _OP_SETATTR: unsafe.Sizeof(AttrOut{}),
......
...@@ -78,7 +78,7 @@ func (me *request) OutputDebug() string { ...@@ -78,7 +78,7 @@ func (me *request) OutputDebug() string {
} }
func (me *request) parse() { func (me *request) parse() {
inHSize := unsafe.Sizeof(InHeader{}) inHSize := int(unsafe.Sizeof(InHeader{}))
if len(me.inputBuf) < inHSize { if len(me.inputBuf) < inHSize {
log.Printf("Short read for input header: %v", me.inputBuf) log.Printf("Short read for input header: %v", me.inputBuf)
return return
...@@ -94,7 +94,7 @@ func (me *request) parse() { ...@@ -94,7 +94,7 @@ func (me *request) parse() {
return return
} }
if len(me.arg) < me.handler.InputSize { if len(me.arg) < int(me.handler.InputSize) {
log.Printf("Short read for %v: %v", me.inHeader.opcode, me.arg) log.Printf("Short read for %v: %v", me.inHeader.opcode, me.arg)
me.status = EIO me.status = EIO
return return
...@@ -135,7 +135,8 @@ func (me *request) serialize() { ...@@ -135,7 +135,8 @@ func (me *request) serialize() {
outHeader := (*OutHeader)(unsafe.Pointer(&me.outHeaderBytes[0])) outHeader := (*OutHeader)(unsafe.Pointer(&me.outHeaderBytes[0]))
outHeader.Unique = me.inHeader.Unique outHeader.Unique = me.inHeader.Unique
outHeader.Status = -me.status outHeader.Status = -me.status
outHeader.Length = uint32(sizeOfOutHeader + dataLength + len(me.flatData)) outHeader.Length = uint32(
int(sizeOfOutHeader) + int(dataLength) + int(len(me.flatData)))
copy(me.outHeaderBytes[sizeOfOutHeader:], asSlice(me.outData, dataLength)) copy(me.outHeaderBytes[sizeOfOutHeader:], asSlice(me.outData, dataLength))
} }
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