mirror of
https://github.com/containers/podman.git
synced 2025-09-10 10:32:19 +08:00
make lint: enable rowserrcheck
It turns out, after iterating over rows, we need to check for errors. It also turns out that we did not do that at all. Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
@ -12,8 +12,6 @@ run:
|
||||
linters:
|
||||
enable-all: true
|
||||
disable:
|
||||
# All these break for one reason or another
|
||||
- rowserrcheck # FIXME (urgent): sqlite error checking
|
||||
# too many reports but requires attention
|
||||
- depguard
|
||||
- revive
|
||||
|
@ -139,6 +139,9 @@ func (s *SQLiteState) Refresh() (defErr error) {
|
||||
|
||||
ctrStates[id] = string(newJSON)
|
||||
}
|
||||
if err := ctrRows.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
podRows, err := s.conn.Query("SELECT ID, JSON FROM PodState;")
|
||||
if err != nil {
|
||||
@ -170,6 +173,9 @@ func (s *SQLiteState) Refresh() (defErr error) {
|
||||
|
||||
podStates[id] = string(newJSON)
|
||||
}
|
||||
if err := podRows.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
volRows, err := s.conn.Query("SELECT Name, JSON FROM VolumeState;")
|
||||
if err != nil {
|
||||
@ -202,6 +208,9 @@ func (s *SQLiteState) Refresh() (defErr error) {
|
||||
|
||||
volumeStates[name] = string(newJSON)
|
||||
}
|
||||
if err := volRows.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Write updated states back to DB, and perform additional maintenance
|
||||
// (Remove exit codes and exec sessions)
|
||||
@ -503,6 +512,9 @@ func (s *SQLiteState) LookupContainerID(idOrName string) (string, error) {
|
||||
}
|
||||
resCount++
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if resCount == 0 {
|
||||
return "", define.ErrNoSuchCtr
|
||||
} else if resCount > 1 {
|
||||
@ -544,6 +556,9 @@ func (s *SQLiteState) LookupContainer(idOrName string) (*Container, error) {
|
||||
}
|
||||
resCount++
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exactName {
|
||||
if resCount == 0 {
|
||||
return nil, fmt.Errorf("no container with name or ID %q found: %w", idOrName, define.ErrNoSuchCtr)
|
||||
@ -730,6 +745,9 @@ func (s *SQLiteState) ContainerInUse(ctr *Container) ([]string, error) {
|
||||
}
|
||||
deps = append(deps, dep)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return deps, nil
|
||||
}
|
||||
@ -770,6 +788,9 @@ func (s *SQLiteState) AllContainers(loadState bool) ([]*Container, error) {
|
||||
|
||||
ctrs = append(ctrs, ctr)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
rows, err := s.conn.Query("SELECT JSON FROM ContainerConfig;")
|
||||
if err != nil {
|
||||
@ -794,6 +815,9 @@ func (s *SQLiteState) AllContainers(loadState bool) ([]*Container, error) {
|
||||
|
||||
ctrs = append(ctrs, ctr)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
for _, ctr := range ctrs {
|
||||
@ -1095,6 +1119,9 @@ func (s *SQLiteState) GetContainerExecSessions(ctr *Container) ([]string, error)
|
||||
}
|
||||
sessions = append(sessions, session)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return sessions, nil
|
||||
}
|
||||
@ -1332,6 +1359,9 @@ func (s *SQLiteState) LookupPod(idOrName string) (*Pod, error) {
|
||||
}
|
||||
resCount++
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exactName {
|
||||
if resCount == 0 {
|
||||
return nil, fmt.Errorf("no pod with name or ID %s found: %w", idOrName, define.ErrNoSuchPod)
|
||||
@ -1421,6 +1451,9 @@ func (s *SQLiteState) PodContainersByID(pod *Pod) ([]string, error) {
|
||||
|
||||
ids = append(ids, id)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return ids, nil
|
||||
}
|
||||
@ -1459,6 +1492,9 @@ func (s *SQLiteState) PodContainers(pod *Pod) ([]*Container, error) {
|
||||
|
||||
ctrs = append(ctrs, ctr)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, ctr := range ctrs {
|
||||
if err := finalizeCtrSqlite(ctr); err != nil {
|
||||
@ -1652,6 +1688,9 @@ func (s *SQLiteState) RemovePodContainers(pod *Pod) (defErr error) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -1804,6 +1843,9 @@ func (s *SQLiteState) AllPods() ([]*Pod, error) {
|
||||
|
||||
pods = append(pods, pod)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return pods, nil
|
||||
}
|
||||
@ -1910,6 +1952,9 @@ func (s *SQLiteState) RemoveVolume(volume *Volume) (defErr error) {
|
||||
}
|
||||
ctrs = append(ctrs, ctr)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(ctrs) > 0 {
|
||||
return fmt.Errorf("volume %s is in use by containers %s: %w", volume.Name(), strings.Join(ctrs, ","), define.ErrVolumeBeingUsed)
|
||||
}
|
||||
@ -2045,6 +2090,9 @@ func (s *SQLiteState) AllVolumes() ([]*Volume, error) {
|
||||
|
||||
volumes = append(volumes, vol)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return volumes, nil
|
||||
}
|
||||
@ -2113,6 +2161,9 @@ func (s *SQLiteState) LookupVolume(name string) (*Volume, error) {
|
||||
break
|
||||
}
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if foundName == "" {
|
||||
return nil, fmt.Errorf("no volume with name %q found: %w", name, define.ErrNoSuchVolume)
|
||||
}
|
||||
@ -2186,6 +2237,9 @@ func (s *SQLiteState) VolumeInUse(volume *Volume) ([]string, error) {
|
||||
}
|
||||
ctrs = append(ctrs, ctr)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return ctrs, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user