Skip to content

Commit 4e621a3

Browse files
committed
api/server: explicitly ignore unhandled errors (errcheck)
``` api/server/router/build/build_routes.go:309:41: Error return value of `(*encoding/json.Decoder).Decode` is not checked (errcheck) api/server/router/build/build_routes.go:431:11: Error return value of `io.Copy` is not checked (errcheck) api/server/router/container/container_routes.go:582:13: Error return value of `conn.Write` is not checked (errcheck) api/server/router/grpc/grpc_routes.go:38:12: Error return value of `conn.Write` is not checked (errcheck) api/server/router/grpc/grpc_routes.go:39:12: Error return value of `resp.Write` is not checked (errcheck) api/server/router/image/image_routes.go:94:15: Error return value of `output.Write` is not checked (errcheck) api/server/router/image/image_routes.go:139:15: Error return value of `output.Write` is not checked (errcheck) api/server/router/image/image_routes.go:164:15: Error return value of `output.Write` is not checked (errcheck) api/server/router/image/image_routes.go:180:15: Error return value of `output.Write` is not checked (errcheck) api/server/router/plugin/plugin_routes.go:126:15: Error return value of `output.Write` is not checked (errcheck) api/server/router/plugin/plugin_routes.go:165:15: Error return value of `output.Write` is not checked (errcheck) api/server/router/plugin/plugin_routes.go:273:15: Error return value of `output.Write` is not checked (errcheck) ``` Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 6ff727b commit 4e621a3

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

api/server/router/build/build_routes.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func (br *buildRouter) postPrune(ctx context.Context, w http.ResponseWriter, r *
176176
if err := httputils.ParseForm(r); err != nil {
177177
return err
178178
}
179-
filters, err := filters.FromJSON(r.Form.Get("filters"))
179+
fltrs, err := filters.FromJSON(r.Form.Get("filters"))
180180
if err != nil {
181181
return errors.Wrap(err, "could not parse filters")
182182
}
@@ -191,7 +191,7 @@ func (br *buildRouter) postPrune(ctx context.Context, w http.ResponseWriter, r *
191191

192192
opts := types.BuildCachePruneOptions{
193193
All: httputils.BoolValue(r, "all"),
194-
Filters: filters,
194+
Filters: fltrs,
195195
KeepStorage: int64(ks),
196196
}
197197

@@ -234,12 +234,12 @@ func (br *buildRouter) postBuild(ctx context.Context, w http.ResponseWriter, r *
234234
}
235235

236236
output := ioutils.NewWriteFlusher(ww)
237-
defer output.Close()
237+
defer func() { _ = output.Close() }()
238238

239239
errf := func(err error) error {
240240

241241
if httputils.BoolValue(r, "q") && notVerboseBuffer.Len() > 0 {
242-
output.Write(notVerboseBuffer.Bytes())
242+
_, _ = output.Write(notVerboseBuffer.Bytes())
243243
}
244244

245245
// Do not write the error in the http output if it's still empty.
@@ -290,7 +290,7 @@ func (br *buildRouter) postBuild(ctx context.Context, w http.ResponseWriter, r *
290290
// Everything worked so if -q was provided the output from the daemon
291291
// should be just the image ID and we'll print that to stdout.
292292
if buildOptions.SuppressOutput {
293-
fmt.Fprintln(streamformatter.NewStdoutWriter(output), imgID)
293+
_, _ = fmt.Fprintln(streamformatter.NewStdoutWriter(output), imgID)
294294
}
295295
return nil
296296
}
@@ -306,7 +306,7 @@ func getAuthConfigs(header http.Header) map[string]types.AuthConfig {
306306
authConfigsJSON := base64.NewDecoder(base64.URLEncoding, strings.NewReader(authConfigsEncoded))
307307
// Pulling an image does not error when no auth is provided so to remain
308308
// consistent with the existing api decode errors are ignored
309-
json.NewDecoder(authConfigsJSON).Decode(&authConfigs)
309+
_ = json.NewDecoder(authConfigsJSON).Decode(&authConfigs)
310310
return authConfigs
311311
}
312312

@@ -428,7 +428,7 @@ func (w *wcf) notify() {
428428
w.mu.Lock()
429429
if !w.ready {
430430
if w.buf.Len() > 0 {
431-
io.Copy(w.Writer, w.buf)
431+
_, _ = io.Copy(w.Writer, w.buf)
432432
}
433433
if w.flushed {
434434
w.flusher.Flush()

api/server/router/image/image_routes.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (s *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWrite
9191
if !output.Flushed() {
9292
return err
9393
}
94-
output.Write(streamformatter.FormatError(err))
94+
_, _ = output.Write(streamformatter.FormatError(err))
9595
}
9696

9797
return nil
@@ -136,7 +136,7 @@ func (s *imageRouter) postImagesPush(ctx context.Context, w http.ResponseWriter,
136136
if !output.Flushed() {
137137
return err
138138
}
139-
output.Write(streamformatter.FormatError(err))
139+
_, _ = output.Write(streamformatter.FormatError(err))
140140
}
141141
return nil
142142
}
@@ -161,7 +161,7 @@ func (s *imageRouter) getImagesGet(ctx context.Context, w http.ResponseWriter, r
161161
if !output.Flushed() {
162162
return err
163163
}
164-
output.Write(streamformatter.FormatError(err))
164+
_, _ = output.Write(streamformatter.FormatError(err))
165165
}
166166
return nil
167167
}
@@ -177,7 +177,7 @@ func (s *imageRouter) postImagesLoad(ctx context.Context, w http.ResponseWriter,
177177
output := ioutils.NewWriteFlusher(w)
178178
defer output.Close()
179179
if err := s.backend.LoadImage(r.Body, output, quiet); err != nil {
180-
output.Write(streamformatter.FormatError(err))
180+
_, _ = output.Write(streamformatter.FormatError(err))
181181
}
182182
return nil
183183
}

api/server/router/plugin/plugin_routes.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func (pr *pluginRouter) upgradePlugin(ctx context.Context, w http.ResponseWriter
123123
if !output.Flushed() {
124124
return err
125125
}
126-
output.Write(streamformatter.FormatError(err))
126+
_, _ = output.Write(streamformatter.FormatError(err))
127127
}
128128

129129
return nil
@@ -162,7 +162,7 @@ func (pr *pluginRouter) pullPlugin(ctx context.Context, w http.ResponseWriter, r
162162
if !output.Flushed() {
163163
return err
164164
}
165-
output.Write(streamformatter.FormatError(err))
165+
_, _ = output.Write(streamformatter.FormatError(err))
166166
}
167167

168168
return nil
@@ -270,7 +270,7 @@ func (pr *pluginRouter) pushPlugin(ctx context.Context, w http.ResponseWriter, r
270270
if !output.Flushed() {
271271
return err
272272
}
273-
output.Write(streamformatter.FormatError(err))
273+
_, _ = output.Write(streamformatter.FormatError(err))
274274
}
275275
return nil
276276
}

0 commit comments

Comments
 (0)