Comparison

util-src/pposix.c @ 4415:0091db139229

util.pposix: Don't trust errno for success. Thanks Quince
author Kim Alvefur <zash@zash.se>
date Fri, 18 Nov 2011 06:13:24 +0100
parent 3966:e71c19dac1c7
child 4934:5a6a85719b7b
comparison
equal deleted inserted replaced
4413:ffa4bed1b716 4415:0091db139229
393 lua_pushnil(L); 393 lua_pushnil(L);
394 lua_pushstring(L, "invalid-gid"); 394 lua_pushstring(L, "invalid-gid");
395 return 2; 395 return 2;
396 } 396 }
397 ret = initgroups(lua_tostring(L, 1), gid); 397 ret = initgroups(lua_tostring(L, 1), gid);
398 switch(errno) 398 if(ret)
399 { 399 {
400 case 0: 400 switch(errno)
401 {
402 case ENOMEM:
403 lua_pushnil(L);
404 lua_pushstring(L, "no-memory");
405 break;
406 case EPERM:
407 lua_pushnil(L);
408 lua_pushstring(L, "permission-denied");
409 break;
410 default:
411 lua_pushnil(L);
412 lua_pushstring(L, "unknown-error");
413 }
414 }
415 else
416 {
401 lua_pushboolean(L, 1); 417 lua_pushboolean(L, 1);
402 lua_pushnil(L); 418 lua_pushnil(L);
403 break;
404 case ENOMEM:
405 lua_pushnil(L);
406 lua_pushstring(L, "no-memory");
407 break;
408 case EPERM:
409 lua_pushnil(L);
410 lua_pushstring(L, "permission-denied");
411 break;
412 default:
413 lua_pushnil(L);
414 lua_pushstring(L, "unknown-error");
415 } 419 }
416 return 2; 420 return 2;
417 } 421 }
418 422
419 int lc_umask(lua_State* L) 423 int lc_umask(lua_State* L)