aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2013-04-17 12:40:39 +0200
committerGravatar Christian Hesse <mail@eworm.de>2013-04-17 12:40:39 +0200
commitbbf4048065cafcc55c186468b0a1cfc1a1bc2236 (patch)
treeaa4b8dbd7ebfa7ffd5fdd12cd99e06e1a77b4b20
parent7949d5198d4a8c452588bbf4b3ea47499e315de9 (diff)
downloadudev-block-notify-bbf4048065cafcc55c186468b0a1cfc1a1bc2236.tar.gz
udev-block-notify-bbf4048065cafcc55c186468b0a1cfc1a1bc2236.tar.zst
no need to pass NULL pointer
-rw-r--r--udev-block-notify.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/udev-block-notify.c b/udev-block-notify.c
index 44f2f4c..5f1d786 100644
--- a/udev-block-notify.c
+++ b/udev-block-notify.c
@@ -34,7 +34,9 @@
#define TEXT_DEFAULT "Anything happend to <b>%s</b> (%i:%i)... Don't know."
#define TEXT_TAG "\n%s: <i>%s</i>"
-char * newstr(char *text, char *notifystr, char *device, unsigned short int major, unsigned short int minor) {
+char * newstr(char *text, char *device, unsigned short int major, unsigned short int minor) {
+ char *notifystr;
+
notifystr = malloc(strlen(text) + strlen(device) + 10 /* max string length 2* unsigned short int */);
sprintf(notifystr, text, device, major, minor);
@@ -106,27 +108,27 @@ int main (int argc, char ** argv) {
switch(action) {
case 'a':
// a: add
- notifystr = newstr(TEXT_ADD, notifystr, device, major, minor);
+ notifystr = newstr(TEXT_ADD, device, major, minor);
icon = ICON_ADD;
break;
case 'r':
// r: remove
- notifystr = newstr(TEXT_REMOVE, notifystr, device, major, minor);
+ notifystr = newstr(TEXT_REMOVE, device, major, minor);
icon = ICON_REMOVE;
break;
case 'm':
// m: move
- notifystr = newstr(TEXT_MOVE, notifystr, device, major, minor);
+ notifystr = newstr(TEXT_MOVE, device, major, minor);
icon = ICON_MOVE;
break;
case 'c':
// c: change
- notifystr = newstr(TEXT_CHANGE, notifystr, device, major, minor);
+ notifystr = newstr(TEXT_CHANGE, device, major, minor);
icon = ICON_CHANGE;
break;
default:
// we should never get here I think...
- notifystr = newstr(TEXT_DEFAULT, notifystr, device, major, minor);
+ notifystr = newstr(TEXT_DEFAULT, device, major, minor);
icon = ICON_DEFAULT;
}