[libblockdev 01/10] Do not start using next_line until needed.
mulhern
amulhern at redhat.com
Wed Jun 25 21:35:30 UTC 2014
If the while loop is reached file_content will not have changed.
Signed-off-by: mulhern <amulhern at redhat.com>
---
src/plugins/swap.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/plugins/swap.c b/src/plugins/swap.c
index 254e9ca..bd75fbf 100644
--- a/src/plugins/swap.c
+++ b/src/plugins/swap.c
@@ -234,16 +234,15 @@ gboolean bd_swap_swapstatus (gchar *device, gchar **error_message) {
/* no error, set *error_message to NULL to show it */
*error_message = NULL;
- next_line = file_content;
- if (g_str_has_prefix (next_line, real_device ? real_device : device)) {
+ if (g_str_has_prefix (file_content, real_device ? real_device : device)) {
g_free (symlink);
g_free (real_device);
g_free (file_content);
return TRUE;
}
- next_line = (strchr (next_line, '\n') + 1);
- while (next_line && ((next_line - file_content) < length)) {
+ next_line = (strchr (file_content, '\n') + 1);
+ while (next_line && ((unsigned)(next_line - file_content) < length)) {
if (g_str_has_prefix (next_line, real_device ? real_device : device)) {
g_free (symlink);
g_free (real_device);
--
1.9.3
More information about the anaconda-patches
mailing list