Use return value as success indicator
This commit is contained in:
		
							parent
							
								
									92543cce22
								
							
						
					
					
						commit
						e82b7bfb2d
					
				
							
								
								
									
										37
									
								
								src/dbus.c
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								src/dbus.c
									
									
									
									
									
								
							| @ -432,28 +432,33 @@ static void on_name_acquired(GDBusConnection *connection, | |||||||
|         dbus_conn = connection; |         dbus_conn = connection; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /*
 | /**
 | ||||||
|  * Get the PID of the current process, which acquired FDN DBus Name. |  * Get the PID of the current process, which acquired FDN DBus Name. | ||||||
|  * |  * | ||||||
|  * If name or vendor specified, the name and vendor |  * If name or vendor specified, the name and vendor | ||||||
|  * will get additionally get via the FDN GetServerInformation method |  * will get additionally get via the FDN GetServerInformation method | ||||||
|  * |  * | ||||||
|  * Returns: valid PID, else -1 |  * @param connection The dbus connection | ||||||
|  |  * @param pid The place to report the PID to | ||||||
|  |  * @param name The place to report the name to, if not required set to NULL | ||||||
|  |  * @param vendor The place to report the vendor to, if not required set to NULL | ||||||
|  |  * | ||||||
|  |  * @returns `true` on success, otherwise `false` | ||||||
|  */ |  */ | ||||||
| static int dbus_get_fdn_daemon_info(GDBusConnection  *connection, | static bool dbus_get_fdn_daemon_info(GDBusConnection  *connection, | ||||||
|                                        char **name, |                                     int   *pid, | ||||||
|                                        char **vendor) |                                     char **name, | ||||||
|  |                                     char **vendor) | ||||||
| { | { | ||||||
|  |         g_return_val_if_fail(pid, false); | ||||||
|  |         g_return_val_if_fail(connection, false); | ||||||
|  | 
 | ||||||
|         char *owner = NULL; |         char *owner = NULL; | ||||||
|         GError *error = NULL; |         GError *error = NULL; | ||||||
|         int pid = -1; |  | ||||||
| 
 | 
 | ||||||
|         GDBusProxy *proxy_fdn; |         GDBusProxy *proxy_fdn; | ||||||
|         GDBusProxy *proxy_dbus; |         GDBusProxy *proxy_dbus; | ||||||
| 
 | 
 | ||||||
|         if (!connection) |  | ||||||
|                 return pid; |  | ||||||
| 
 |  | ||||||
|         proxy_fdn = g_dbus_proxy_new_sync( |         proxy_fdn = g_dbus_proxy_new_sync( | ||||||
|                                      connection, |                                      connection, | ||||||
|                                      /* do not trigger a start of the notification daemon */ |                                      /* do not trigger a start of the notification daemon */ | ||||||
| @ -467,7 +472,7 @@ static int dbus_get_fdn_daemon_info(GDBusConnection  *connection, | |||||||
| 
 | 
 | ||||||
|         if (error) { |         if (error) { | ||||||
|                 g_error_free(error); |                 g_error_free(error); | ||||||
|                 return pid; |                 return false; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         GVariant *daemoninfo; |         GVariant *daemoninfo; | ||||||
| @ -505,7 +510,7 @@ static int dbus_get_fdn_daemon_info(GDBusConnection  *connection, | |||||||
| 
 | 
 | ||||||
|         if (error) { |         if (error) { | ||||||
|                 g_error_free(error); |                 g_error_free(error); | ||||||
|                 return pid; |                 return false; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         GVariant *pidinfo = g_dbus_proxy_call_sync( |         GVariant *pidinfo = g_dbus_proxy_call_sync( | ||||||
| @ -521,7 +526,7 @@ static int dbus_get_fdn_daemon_info(GDBusConnection  *connection, | |||||||
| 
 | 
 | ||||||
|         if (error) { |         if (error) { | ||||||
|                 g_error_free(error); |                 g_error_free(error); | ||||||
|                 return pid; |                 return false; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         g_variant_get(pidinfo, "(u)", &pid); |         g_variant_get(pidinfo, "(u)", &pid); | ||||||
| @ -534,7 +539,7 @@ static int dbus_get_fdn_daemon_info(GDBusConnection  *connection, | |||||||
|         if (pidinfo) |         if (pidinfo) | ||||||
|                 g_variant_unref(pidinfo); |                 g_variant_unref(pidinfo); | ||||||
| 
 | 
 | ||||||
|         return pid; |         return true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -543,9 +548,9 @@ static void on_name_lost(GDBusConnection *connection, | |||||||
|                          gpointer user_data) |                          gpointer user_data) | ||||||
| { | { | ||||||
|         if (connection) { |         if (connection) { | ||||||
|                 char *name = NULL; |                 char *name; | ||||||
|                 int pid = dbus_get_fdn_daemon_info(connection, &name, NULL); |                 int pid; | ||||||
|                 if (pid > 0) { |                 if (dbus_get_fdn_daemon_info(connection, &pid, &name, NULL)) { | ||||||
|                         DIE("Cannot acquire '"FDN_NAME"': " |                         DIE("Cannot acquire '"FDN_NAME"': " | ||||||
|                             "Name is acquired by '%s' with PID '%d'.", name, pid); |                             "Name is acquired by '%s' with PID '%d'.", name, pid); | ||||||
|                 } else { |                 } else { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Benedikt Heine
						Benedikt Heine