code cleanup: Omit redundant nil check on slices

This commit is contained in:
卢振兴10069964 2021-04-12 09:00:36 +08:00
parent a55bd63172
commit a36c5f08f4
4 changed files with 5 additions and 5 deletions

View File

@ -326,7 +326,7 @@ func removeNodeIDFromNode(csiDriverName string) nodeUpdateFunc {
// topology information.
func updateTopologyLabels(topology map[string]string) nodeUpdateFunc {
return func(node *v1.Node) (*v1.Node, bool, error) {
if topology == nil || len(topology) == 0 {
if len(topology) == 0 {
return node, false, nil
}

View File

@ -791,7 +791,7 @@ func extractDeviceAndPrefix(mntPath string) (string, string, error) {
func extractIface(mntPath string) (string, bool) {
reOutput := ifaceRe.FindStringSubmatch(mntPath)
if reOutput != nil && len(reOutput) > 1 {
if len(reOutput) > 1 {
return reOutput[1], true
}

View File

@ -380,9 +380,9 @@ func (plugin *FakeVolumePlugin) NewDetacher() (Detacher, error) {
plugin.NewDetacherCallCount = plugin.NewDetacherCallCount + 1
detacher := plugin.getFakeVolume(&plugin.Detachers)
attacherList := plugin.Attachers
if attacherList != nil && len(attacherList) > 0 {
if len(attacherList) > 0 {
detacherList := plugin.Detachers
if detacherList != nil && len(detacherList) > 0 {
if len(detacherList) > 0 {
detacherList[0].VolumesAttached = attacherList[0].VolumesAttached
}

View File

@ -181,7 +181,7 @@ func Invalid(field *Path, value interface{}, detail string) *Error {
// valid values).
func NotSupported(field *Path, value interface{}, validValues []string) *Error {
detail := ""
if validValues != nil && len(validValues) > 0 {
if len(validValues) > 0 {
quotedValues := make([]string, len(validValues))
for i, v := range validValues {
quotedValues[i] = strconv.Quote(v)