Merge lp:~sense/notify-osd/fix-465801 into lp:notify-osd/trunk

Proposed by Sense Egbert Hofstede
Status: Merged
Approved by: Mirco Müller
Approved revision: not available
Merge reported by: Mirco Müller
Merged at revision: not available
Proposed branch: lp:~sense/notify-osd/fix-465801
Merge into: lp:notify-osd/trunk
Diff against target: 33 lines
1 file modified
src/log.c (+3/-4)
To merge this branch: bzr merge lp:~sense/notify-osd/fix-465801
Reviewer Review Type Date Requested Status
Mirco Müller (community) Approve
Review via email: mp+14265@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Sense Egbert Hofstede (sense) wrote :

These changes fix bug #465801 and have been tested and found to be working.
The variable dirname in src/log.c is now a const gchar* and is not freed. Instead of hardcoding the use of ~/.cache, now the function g_get_user_cache_dir() is used. Therefore <glib.h> is included in src/log.c

Revision history for this message
Robert Collins (lifeless) wrote :

Looks sane to me, though I'm not a notify-OSD committer.

It would be good to factor out the logfile name selection and add a test
to demonstrate that your needs are met, but if you don't feel like
doing that, perhaps a comment [so that this doesn't get changed
incorrectly in the future] would be useful.

-Rob

Revision history for this message
Ted Gould (ted) wrote :

This should use g_build_path instead of the g_strdup_printf. It should look like:

g_build_path(dirname, "notify-osd.log", NULL);

That way it handles all the fishyness that could be in the path. Technically it's also cross-platform safe, but I doubt anyone will port Notify OSD to windows ;)

lp:~sense/notify-osd/fix-465801 updated
410. By Sense Egbert Hofstede

Use g_build_filename () in src/log.c to determine the log file path.

Revision history for this message
Sense Egbert Hofstede (sense) wrote :

I've replaced g_strdup_printf () with g_build_filename ().
However, I don't fully understand Robert Collins. Did you suggest to move the name selection to a function? And what tests would you suggest to add?

Revision history for this message
Mirco Müller (macslow) wrote :

I also am not sure what Robert means with "your needs are met". That aside your changes up to rev410 look good. Thanks Ted, for you suggestion to make writing to the cache-file cross-platform :)

Revision history for this message
Robert Collins (lifeless) wrote :

What I mean is:
 - the change is being made because something is wrong
 - a test that demonstrates the wrongness would prevent it being
reintroduced later
 - 'your needs' are whatever you want notify-osd to do differently than
it does.

-Rob

Revision history for this message
Sense Egbert Hofstede (sense) wrote :

What I want Notify OSD to do different is storing the log file. Currently it is hard coded to save the file in .cache, but I would like Notify OSD to adhere to the FreeDesktop standards and use the appointed variable for getting the cache directory.

How to test: a test doesn't need to be written, it can be tested by exporting a different directory to $XDG_CACHE_HOME and restart the version of Notify OSD in this branch.

Revision history for this message
Mirco Müller (macslow) wrote :

I'll test-run and merge that with other notify-osd related work once I'm back home from UDS next week.

Revision history for this message
Mirco Müller (macslow) wrote :

BTW, thanks for the fix. I'll add that to notify-osd SRU for Karmic (and hope it'll get accepted by the desktop-team).

review: Approve
Revision history for this message
David Barth (dbarth) wrote :

Thanks for the patch. Per company policy, we need you to accept the Canonical Contributor Agreement, and the copyright assignment that goes with it. More information at: http://www.canonical.com/contributors

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/log.c'
2--- src/log.c 2009-04-09 07:33:35 +0000
3+++ src/log.c 2009-11-01 10:48:11 +0000
4@@ -30,6 +30,7 @@
5 #include <sys/time.h>
6 #include <time.h>
7 #include <stdio.h>
8+#include <glib.h>
9
10 #include "bubble.h"
11
12@@ -53,11 +54,10 @@
13 g_return_if_fail (homedir != NULL);
14
15 // Make sure the cache directory is there, if at all possible
16- char *dirname = g_strdup_printf ("%s/.cache", homedir);
17+ const gchar *dirname = g_get_user_cache_dir ();
18 g_mkdir_with_parents (dirname, 0700);
19
20- char *filename =
21- g_strdup_printf ("%s/.cache/notify-osd.log", homedir);
22+ char *filename = g_build_filename (dirname, "notify-osd.log", NULL);
23
24 logfile = fopen (filename, "w");
25 if (logfile == NULL)
26@@ -65,7 +65,6 @@
27 filename);
28
29 g_free (filename);
30- g_free (dirname);
31
32 /* discard all debug messages unless DEBUG is set */
33 if (! g_getenv ("DEBUG"))

Subscribers

People subscribed via source and target branches