Refactoring ineffectual assignments

This patch fixed below 4 types of code line
1. Remove unnecessary variable assignment
2. Use variables declaration instead of explicit initial zero value
3. Change variable name to underbar when variable not used
4. Add erro check and return for ignored error

Signed-off-by: Daehyeok Mun <daehyeok@gmail.com>
Upstream-commit: 6306019d0bad9c4e60ee437e93f2450dfb0b68c0
Component: engine
This commit is contained in:
Daehyeok Mun
2017-01-13 00:27:01 -07:00
parent a9065717ae
commit 287ee51be3
12 changed files with 25 additions and 29 deletions
@@ -81,14 +81,11 @@ func collect(ctx context.Context, s *formatter.ContainerStats, cli client.APICli
go func() {
for {
var (
v *types.StatsJSON
memPercent = 0.0
cpuPercent = 0.0
blkRead, blkWrite uint64 // Only used on Linux
mem = 0.0
memLimit = 0.0
memPerc = 0.0
pidsStatsCurrent uint64
v *types.StatsJSON
memPercent, cpuPercent float64
blkRead, blkWrite uint64 // Only used on Linux
mem, memLimit, memPerc float64
pidsStatsCurrent uint64
)
if err := dec.Decode(&v); err != nil {
@@ -41,7 +41,9 @@ func validateConfig(path string) error {
// validateContextDir validates the given dir and returns abs path on success.
func validateContextDir(contextDir string) (string, error) {
absContextDir, err := filepath.Abs(contextDir)
if err != nil {
return "", err
}
stat, err := os.Lstat(absContextDir)
if err != nil {
return "", err