Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(896)

Delta Between Two Patch Sets: src/pkg/net/fd_unix.go

Issue 6845062: code review 6845062: net: remove another unguarded sysfile == nil check (Closed)
Left Patch Set: Created 11 years, 4 months ago
Right Patch Set: diff -r 1315abc581ed https://go.googlecode.com/hg/ Created 11 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // +build darwin freebsd linux netbsd openbsd 5 // +build darwin freebsd linux netbsd openbsd
6 6
7 package net 7 package net
8 8
9 import ( 9 import (
10 "io" 10 "io"
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 return 502 return
503 } 503 }
504 504
505 func (fd *netFD) Write(p []byte) (int, error) { 505 func (fd *netFD) Write(p []byte) (int, error) {
506 fd.wio.Lock() 506 fd.wio.Lock()
507 defer fd.wio.Unlock() 507 defer fd.wio.Unlock()
508 if err := fd.incref(false); err != nil { 508 if err := fd.incref(false); err != nil {
509 return 0, err 509 return 0, err
510 } 510 }
511 defer fd.decref() 511 defer fd.decref()
512 if fd.sysfile == nil {
513 return 0, syscall.EINVAL
514 }
515
516 var err error 512 var err error
517 nn := 0 513 nn := 0
518 for { 514 for {
519 var n int 515 var n int
520 n, err = syscall.Write(int(fd.sysfd), p[nn:]) 516 n, err = syscall.Write(int(fd.sysfd), p[nn:])
521 if n > 0 { 517 if n > 0 {
522 nn += n 518 nn += n
523 } 519 }
524 if nn == len(p) { 520 if nn == len(p) {
525 break 521 break
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 if err = syscall.SetNonblock(ns, false); err != nil { 656 if err = syscall.SetNonblock(ns, false); err != nil {
661 return nil, &OpError{"setnonblock", fd.net, fd.laddr, err} 657 return nil, &OpError{"setnonblock", fd.net, fd.laddr, err}
662 } 658 }
663 659
664 return os.NewFile(uintptr(ns), fd.name()), nil 660 return os.NewFile(uintptr(ns), fd.name()), nil
665 } 661 }
666 662
667 func closesocket(s int) error { 663 func closesocket(s int) error {
668 return syscall.Close(s) 664 return syscall.Close(s)
669 } 665 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b