diff mbox

lib: fwts_battery: fix no fclose() after fopen is called.

Message ID 1337677399-18844-1-git-send-email-alex.hung@canonical.com
State Accepted
Headers show

Commit Message

Alex Hung May 22, 2012, 9:03 a.m. UTC
Signed-off-by: Alex Hung <alex.hung@canonical.com>
---
 src/lib/src/fwts_battery.c |    4 ++++
 1 file changed, 4 insertions(+)

Comments

Colin Ian King May 22, 2012, 8:19 p.m. UTC | #1
Well spotted, this originated from my lame code. I will check if I've 
done this in other places too.

Colin

On 22/05/12 10:03, Alex Hung wrote:
> Signed-off-by: Alex Hung <alex.hung@canonical.com>
> ---
>   src/lib/src/fwts_battery.c |    4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/src/lib/src/fwts_battery.c b/src/lib/src/fwts_battery.c
> index d8cc318..5f21dfa 100644
> --- a/src/lib/src/fwts_battery.c
> +++ b/src/lib/src/fwts_battery.c
> @@ -101,6 +101,7 @@ static int fwts_battery_get_capacity_sys_fs(fwts_framework *fw,
>   						(*count)++;
>   					}
>   				}
> +				fclose(fp);
>   			}
>   		}
>   	} while (entry);
> @@ -167,6 +168,7 @@ static int fwts_battery_get_capacity_proc_fs(fwts_framework *fw,
>   						break;
>   					}
>   				}
> +				fclose(fp);
>   			}
>   		}
>   	} while (entry);
> @@ -307,6 +309,7 @@ static int fwts_battery_get_cycle_count_sys_fs(fwts_framework *fw, DIR *dir, int
>   						*cycle_count = val;
>   					}
>   				}
> +				fclose(fp);
>   			}
>   		}
>   	} while (entry);
> @@ -350,6 +353,7 @@ static int fwts_battery_get_cycle_count_proc_fs(fwts_framework *fw, DIR *dir, in
>   						break;
>   					}
>   				}
> +				fclose(fp);
>   			}
>   		}
>   	} while (entry);
>
Keng-Yu Lin May 23, 2012, 6:11 a.m. UTC | #2
On Tue, May 22, 2012 at 5:03 PM, Alex Hung <alex.hung@canonical.com> wrote:
> Signed-off-by: Alex Hung <alex.hung@canonical.com>
> ---
>  src/lib/src/fwts_battery.c |    4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/src/lib/src/fwts_battery.c b/src/lib/src/fwts_battery.c
> index d8cc318..5f21dfa 100644
> --- a/src/lib/src/fwts_battery.c
> +++ b/src/lib/src/fwts_battery.c
> @@ -101,6 +101,7 @@ static int fwts_battery_get_capacity_sys_fs(fwts_framework *fw,
>                                                (*count)++;
>                                        }
>                                }
> +                               fclose(fp);
>                        }
>                }
>        } while (entry);
> @@ -167,6 +168,7 @@ static int fwts_battery_get_capacity_proc_fs(fwts_framework *fw,
>                                                break;
>                                        }
>                                }
> +                               fclose(fp);
>                        }
>                }
>        } while (entry);
> @@ -307,6 +309,7 @@ static int fwts_battery_get_cycle_count_sys_fs(fwts_framework *fw, DIR *dir, int
>                                                *cycle_count = val;
>                                        }
>                                }
> +                               fclose(fp);
>                        }
>                }
>        } while (entry);
> @@ -350,6 +353,7 @@ static int fwts_battery_get_cycle_count_proc_fs(fwts_framework *fw, DIR *dir, in
>                                                break;
>                                        }
>                                }
> +                               fclose(fp);
>                        }
>                }
>        } while (entry);
> --
> 1.7.9.5
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
diff mbox

Patch

diff --git a/src/lib/src/fwts_battery.c b/src/lib/src/fwts_battery.c
index d8cc318..5f21dfa 100644
--- a/src/lib/src/fwts_battery.c
+++ b/src/lib/src/fwts_battery.c
@@ -101,6 +101,7 @@  static int fwts_battery_get_capacity_sys_fs(fwts_framework *fw,
 						(*count)++;
 					}
 				}
+				fclose(fp);
 			}
 		}
 	} while (entry);
@@ -167,6 +168,7 @@  static int fwts_battery_get_capacity_proc_fs(fwts_framework *fw,
 						break;
 					}
 				}
+				fclose(fp);
 			}
 		}
 	} while (entry);
@@ -307,6 +309,7 @@  static int fwts_battery_get_cycle_count_sys_fs(fwts_framework *fw, DIR *dir, int
 						*cycle_count = val;
 					}
 				}
+				fclose(fp);
 			}
 		}
 	} while (entry);
@@ -350,6 +353,7 @@  static int fwts_battery_get_cycle_count_proc_fs(fwts_framework *fw, DIR *dir, in
 						break;
 					}
 				}
+				fclose(fp);
 			}
 		}
 	} while (entry);