mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	set errno properly in all cases
This commit is contained in:
		
							parent
							
								
									6df029a1b1
								
							
						
					
					
						commit
						c4d32ec804
					
				
					 1 changed files with 14 additions and 3 deletions
				
			
		| 
						 | 
					@ -95,12 +95,15 @@ char *pa_get_user_name(char *s, size_t l) {
 | 
				
			||||||
#elif defined(OS_IS_WIN32) /* HAVE_PWD_H */
 | 
					#elif defined(OS_IS_WIN32) /* HAVE_PWD_H */
 | 
				
			||||||
        DWORD size = sizeof(buf);
 | 
					        DWORD size = sizeof(buf);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!GetUserName(buf, &size))
 | 
					        if (!GetUserName(buf, &size)) {
 | 
				
			||||||
 | 
					            errno = ENOENT;
 | 
				
			||||||
            return NULL;
 | 
					            return NULL;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        p = buf;
 | 
					        p = buf;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#else /* HAVE_PWD_H */
 | 
					#else /* HAVE_PWD_H */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
#endif /* HAVE_PWD_H */
 | 
					#endif /* HAVE_PWD_H */
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -138,6 +141,8 @@ char *pa_get_home_dir(char *s, size_t l) {
 | 
				
			||||||
        return pa_strlcpy(s, e, l);
 | 
					        return pa_strlcpy(s, e, l);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef HAVE_PWD_H
 | 
					#ifdef HAVE_PWD_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    errno = 0;
 | 
				
			||||||
#ifdef HAVE_GETPWUID_R
 | 
					#ifdef HAVE_GETPWUID_R
 | 
				
			||||||
    if (getpwuid_r(getuid(), &pw, buf, sizeof(buf), &r) != 0 || !r) {
 | 
					    if (getpwuid_r(getuid(), &pw, buf, sizeof(buf), &r) != 0 || !r) {
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
| 
						 | 
					@ -145,11 +150,16 @@ char *pa_get_home_dir(char *s, size_t l) {
 | 
				
			||||||
        * that do not support getpwuid_r. */
 | 
					        * that do not support getpwuid_r. */
 | 
				
			||||||
    if ((r = getpwuid(getuid())) == NULL) {
 | 
					    if ((r = getpwuid(getuid())) == NULL) {
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					        if (!errno)
 | 
				
			||||||
 | 
					            errno = ENOENT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return pa_strlcpy(s, r->pw_dir, l);
 | 
					    return pa_strlcpy(s, r->pw_dir, l);
 | 
				
			||||||
#else /* HAVE_PWD_H */
 | 
					#else /* HAVE_PWD_H */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    errno = ENOENT;
 | 
				
			||||||
    return NULL;
 | 
					    return NULL;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -200,6 +210,7 @@ char *pa_get_binary_name(char *s, size_t l) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    errno = ENOENT;
 | 
				
			||||||
    return NULL;
 | 
					    return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -249,8 +260,8 @@ int pa_msleep(unsigned long t) {
 | 
				
			||||||
#elif defined(HAVE_NANOSLEEP)
 | 
					#elif defined(HAVE_NANOSLEEP)
 | 
				
			||||||
    struct timespec ts;
 | 
					    struct timespec ts;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ts.tv_sec = t/1000;
 | 
					    ts.tv_sec = t/1000UL;
 | 
				
			||||||
    ts.tv_nsec = (t % 1000) * 1000000;
 | 
					    ts.tv_nsec = (t % 1000UL) * 1000000UL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return nanosleep(&ts, NULL);
 | 
					    return nanosleep(&ts, NULL);
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue