Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
de3aac60
Commit
de3aac60
authored
Apr 05, 2011
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gofix: don't rewrite O_APPEND opens
R=r, rog CC=golang-dev
https://golang.org/cl/4364041
parent
7098f3d4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
4 deletions
+16
-4
exec.go
misc/dashboard/builder/exec.go
+1
-1
osopen.go
src/cmd/gofix/osopen.go
+11
-1
osopen_test.go
src/cmd/gofix/osopen_test.go
+2
-0
main.go
src/cmd/goinstall/main.go
+1
-1
generate_cert.go
src/pkg/crypto/tls/generate_cert.go
+1
-1
No files found.
misc/dashboard/builder/exec.go
View file @
de3aac60
...
@@ -49,7 +49,7 @@ func runLog(envv []string, logfile, dir string, argv ...string) (output string,
...
@@ -49,7 +49,7 @@ func runLog(envv []string, logfile, dir string, argv ...string) (output string,
b
:=
new
(
bytes
.
Buffer
)
b
:=
new
(
bytes
.
Buffer
)
var
w
io
.
Writer
=
b
var
w
io
.
Writer
=
b
if
logfile
!=
""
{
if
logfile
!=
""
{
f
,
err
:=
os
.
Create
(
logfile
)
f
,
err
:=
os
.
OpenFile
(
logfile
,
os
.
O_WRONLY
|
os
.
O_CREATE
|
os
.
O_APPEND
,
0666
)
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
...
...
src/cmd/gofix/osopen.go
View file @
de3aac60
...
@@ -70,6 +70,7 @@ func osopen(f *ast.File) bool {
...
@@ -70,6 +70,7 @@ func osopen(f *ast.File) bool {
func
isCreateFlag
(
flag
ast
.
Expr
)
bool
{
func
isCreateFlag
(
flag
ast
.
Expr
)
bool
{
foundCreate
:=
false
foundCreate
:=
false
foundTrunc
:=
false
foundTrunc
:=
false
foundAppend
:=
false
// OR'ing of flags: is O_CREATE on? + or | would be fine; we just look for os.O_CREATE
// OR'ing of flags: is O_CREATE on? + or | would be fine; we just look for os.O_CREATE
// and don't worry about the actual opeator.
// and don't worry about the actual opeator.
p
:=
flag
.
Pos
()
p
:=
flag
.
Pos
()
...
@@ -85,12 +86,21 @@ func isCreateFlag(flag ast.Expr) bool {
...
@@ -85,12 +86,21 @@ func isCreateFlag(flag ast.Expr) bool {
if
isPkgDot
(
lhs
,
"os"
,
"O_TRUNC"
)
{
if
isPkgDot
(
lhs
,
"os"
,
"O_TRUNC"
)
{
foundTrunc
=
true
foundTrunc
=
true
}
}
if
isPkgDot
(
lhs
,
"os"
,
"O_APPEND"
)
{
foundAppend
=
true
}
if
!
isBinary
{
if
!
isBinary
{
break
break
}
}
flag
=
expr
.
X
flag
=
expr
.
X
}
}
if
foundCreate
&&
!
foundTrunc
{
if
!
foundCreate
{
return
false
}
if
foundAppend
{
return
false
}
if
!
foundTrunc
{
warn
(
p
,
"rewrote os.Open with O_CREATE but not O_TRUNC to os.Create"
)
warn
(
p
,
"rewrote os.Open with O_CREATE but not O_TRUNC to os.Create"
)
}
}
return
foundCreate
return
foundCreate
...
...
src/cmd/gofix/osopen_test.go
View file @
de3aac60
...
@@ -27,6 +27,7 @@ func f() {
...
@@ -27,6 +27,7 @@ func f() {
os.Open(a, os.O_CREATE, 0666)
os.Open(a, os.O_CREATE, 0666)
os.Open(a, os.O_CREATE|os.O_TRUNC, 0664)
os.Open(a, os.O_CREATE|os.O_TRUNC, 0664)
os.Open(a, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
os.Open(a, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
os.Open(a, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666)
_ = os.O_CREAT
_ = os.O_CREAT
}
}
`
,
`
,
...
@@ -46,6 +47,7 @@ func f() {
...
@@ -46,6 +47,7 @@ func f() {
os.Create(a)
os.Create(a)
os.Create(a)
os.Create(a)
os.Create(a)
os.Create(a)
os.OpenFile(a, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666)
_ = os.O_CREATE
_ = os.O_CREATE
}
}
`
,
`
,
...
...
src/cmd/goinstall/main.go
View file @
de3aac60
...
@@ -120,7 +120,7 @@ func logPackage(pkg string) {
...
@@ -120,7 +120,7 @@ func logPackage(pkg string) {
if
installedPkgs
[
pkg
]
{
if
installedPkgs
[
pkg
]
{
return
return
}
}
fout
,
err
:=
os
.
Create
(
logfile
)
fout
,
err
:=
os
.
OpenFile
(
logfile
,
os
.
O_WRONLY
|
os
.
O_CREATE
|
os
.
O_APPEND
,
0666
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"%s: %s
\n
"
,
argv0
,
err
)
fmt
.
Fprintf
(
os
.
Stderr
,
"%s: %s
\n
"
,
argv0
,
err
)
return
return
...
...
src/pkg/crypto/tls/generate_cert.go
View file @
de3aac60
...
@@ -59,7 +59,7 @@ func main() {
...
@@ -59,7 +59,7 @@ func main() {
certOut
.
Close
()
certOut
.
Close
()
log
.
Print
(
"written cert.pem
\n
"
)
log
.
Print
(
"written cert.pem
\n
"
)
keyOut
,
err
:=
os
.
OpenFile
(
"key.pem"
,
os
.
O_WRONLY
|
os
.
O_CREAT
,
0600
)
keyOut
,
err
:=
os
.
OpenFile
(
"key.pem"
,
os
.
O_WRONLY
|
os
.
O_CREAT
|
os
.
O_TRUNC
,
0600
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Print
(
"failed to open key.pem for writing:"
,
err
)
log
.
Print
(
"failed to open key.pem for writing:"
,
err
)
return
return
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment