Re: Libification project (SoC)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 16 Mar 2007 19:16:46 -0400
"Shawn O. Pearce" <spearce@xxxxxxxxxxx> wrote:

| "Luiz Fernando N. Capitulino" <lcapitulino@xxxxxxxxxxxxxxx> wrote:
| >  I think the right solution is to get rid of die() from functions that
| > are supposed to be an interface, set errno if needed and return -1
| > or NULL.
| 
| And then make their callers (if they are above the public API layer)
| die instead.  In some cases this might imply an undesirable change
| in the error message produced, as necessary details that are included
| today would be unavailable in the caller.

 Exactly!

 One simple example of an important error message that would be
lost can be found in read-cache.c:read_cache_from():

 o index file smaller than expected

 I've found a possible solution, though.

 Take a look at Rusty's solution for the same problem in
module-init-tools:

"""
/* We use error numbers in a loose translation... */
static const char *insert_moderror(int err)
{
	switch (err) {
	case ENOEXEC:
		return "Invalid module format";
	case ENOENT:
		return "Unknown symbol in module, or unknown parameter (see dmesg)";
	case ENOSYS:
		return "Kernel does not have module support";
	default:
		return strerror(err);
	}
}
"""

 Instead of calling strerror() directly for error generated
when inserting a module, the insmod() function calls insert_moderror()
which provides the desirable mapping.

 I think we could have something like that for each git's
module, eg, git_cache_strerror(), git_commit_strerror() and so on.

 Does this look reasonable?

-- 
Luiz Fernando N. Capitulino
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]