[maemo-commits] [maemo-commits] r15405 - in projects/haf/trunk/hildon-desktop: . debian libhildonwm
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Tue Apr 15 16:55:56 EEST 2008
- Previous message: [maemo-commits] r15404 - projects/haf/hafbuildbot
- Next message: [maemo-commits] r15406 - projects/haf/tags/hildon-desktop
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: novo Date: 2008-04-15 16:55:55 +0300 (Tue, 15 Apr 2008) New Revision: 15405 Modified: projects/haf/trunk/hildon-desktop/ChangeLog projects/haf/trunk/hildon-desktop/configure.ac projects/haf/trunk/hildon-desktop/debian/changelog projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm-util.c Log: 2008-04-15 Rodrigo Novo <rodrigo.novo at nokia.com> * libhildonwm/hd-wm-util.c: fix various small issues found by Coverity on hd_wm_get_vmdata_for_pid(), also reducing function complexity Fixes: NB#80134 (patch by Leonid Moiseichuk) * configure.ac: 2.0.13 Modified: projects/haf/trunk/hildon-desktop/ChangeLog =================================================================== --- projects/haf/trunk/hildon-desktop/ChangeLog 2008-04-15 13:51:07 UTC (rev 15404) +++ projects/haf/trunk/hildon-desktop/ChangeLog 2008-04-15 13:55:55 UTC (rev 15405) @@ -1,5 +1,13 @@ -2008-04-15 Karl Lattimer <karl.lattimer at nokia.com> +2008-04-15 Rodrigo Novo <rodrigo.novo at nokia.com> + * libhildonwm/hd-wm-util.c: fix various small issues found by Coverity on + hd_wm_get_vmdata_for_pid(), also reducing function complexity + Fixes: NB#80134 + (patch by Leonid Moiseichuk) + * configure.ac: 2.0.13 + +2008-04-15 Karl Lattimer <karl.lattimer at nokia.com> + * data/restore-menu.sh: ensure that backup restore from chinook always includes hildon-update-notifier.desktop in the statusbar.conf this is a substandard fix, more information can be found in the file @@ -7,11 +15,11 @@ Fixes: NB#82941 * configure.ac: 2.0.12 -2008-04-08 Rodrigo Novo <rodrigo.novo at nokia.com> +2008-04-08 Rodrigo Novo <rodrigo.novo at nokia.com> * configure.ac: 2.0.11 -2008-04-08 Karl Lattimer <karl.lattimer at nokia.com> +2008-04-08 Karl Lattimer <karl.lattimer at nokia.com> * libhildondesktop/hildon-desktop-notification-manager.c: fix memory leak by correctly freeing pre-allocated hash table Modified: projects/haf/trunk/hildon-desktop/configure.ac =================================================================== --- projects/haf/trunk/hildon-desktop/configure.ac 2008-04-15 13:51:07 UTC (rev 15404) +++ projects/haf/trunk/hildon-desktop/configure.ac 2008-04-15 13:55:55 UTC (rev 15405) @@ -1,6 +1,6 @@ AC_INIT(Makefile.am) -AM_INIT_AUTOMAKE(hildon-desktop, 2.0.12) +AM_INIT_AUTOMAKE(hildon-desktop, 2.0.13) AM_CONFIG_HEADER(config.h) Modified: projects/haf/trunk/hildon-desktop/debian/changelog =================================================================== --- projects/haf/trunk/hildon-desktop/debian/changelog 2008-04-15 13:51:07 UTC (rev 15404) +++ projects/haf/trunk/hildon-desktop/debian/changelog 2008-04-15 13:55:55 UTC (rev 15405) @@ -1,3 +1,13 @@ +hildon-desktop (1:2.0.13-1) sardine; urgency=low + + * libhildonwm/hd-wm-util.c: fix various small issues found by Coverity on + hd_wm_get_vmdata_for_pid(), also reducing function complexity + Fixes: NB#80134 + (patch by Leonid Moiseichuk) + * configure.ac: 2.0.13 + + -- Rodrigo Novo <rodrigo.novo at nokia.com> Tue, 15 Apr 2008 16:51:51 +0300 + hildon-desktop (1:2.0.12-1) sardine; urgency=low * data/restore-menu.sh: ensure that backup restore from chinook Modified: projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm-util.c =================================================================== --- projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm-util.c 2008-04-15 13:51:07 UTC (rev 15404) +++ projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm-util.c 2008-04-15 13:55:55 UTC (rev 15405) @@ -21,13 +21,16 @@ * */ +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #include <gdk/gdkx.h> #include "hd-wm-util.h" -#define BUF_SIZE 80 gulong hd_wm_util_getenv_long (gchar *env_str, gulong val_default) @@ -213,76 +216,30 @@ */ gint hd_wm_get_vmdata_for_pid(gint pid) { - gchar *fname; - const gchar str[7] = "VmData"; - gchar buf[BUF_SIZE]; - int c; - gint i; - gboolean read = FALSE; - FILE *f; - - fname = g_strdup_printf("/proc/%i/status", pid); - f = fopen(fname, "r"); + char buf[2 * 1024]; /* path to /proc/<pid>/status file and contents of status file, 1K is enough */ + int fd; + int vmdata = -1; - if (f == NULL) - { - g_print("No process data available for %s\n", fname); - g_free (fname); - return -1; - } - - g_free (fname); - - do + snprintf(buf, sizeof(buf), "/proc/%i/status", pid); + fd = open(buf, O_RDONLY); + if (fd < 0) { - c = fgetc(f); - if (c == EOF) - { - break; - } - /* Match incrementally until we find the string "VmData" */ - for (i = 0; i < 6; i++) + g_print("No process data available for %s\n", buf); + } + else + { + if (read(fd, buf, sizeof(buf)) > 0) { - if (c != str[i]) - { - break; - } - c = fgetc(f); - if (i == 5) - { - read = TRUE; - break; - } + /* Process and convert VmData string to number */ + static const char szVmData[] = "VmData:"; + const char* ptr = strstr(buf, szVmData); + + if (ptr && (vmdata = atoi(ptr + sizeof(szVmData))) <= 0) + vmdata = -1; } - if (read == TRUE) - { - /* Skip extra chars */ - while (c != 32 && c != EOF && c != '\n') - { - c = fgetc(f); - } - /* Skip whitespace */ - while (c == 32 && c != EOF && c != '\n') - { - c = fgetc(f); - } - /* Read the number */ - i = 0; - while (c != 32 && c != EOF && c != '\n' && i < BUF_SIZE) - { - buf[i] = c; - i++; - c = fgetc(f); - } - fclose (f); - return (atoi(buf)); - break; - } - - } while (c != EOF); + close(fd); + } - /* Failed, return -1 */ - - return -1; -} + return (gint)vmdata; +} /* hd_wm_get_vmdata_for_pid */
- Previous message: [maemo-commits] r15404 - projects/haf/hafbuildbot
- Next message: [maemo-commits] r15406 - projects/haf/tags/hildon-desktop
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]