Index: [thread] [date] [subject] [author]
  From: Marcus Sundberg <mackan@stacken.kth.se>
  To  : ggi-develop@eskimo.com
  Date: Sun, 15 Aug 1999 18:54:39 +0200

Re: Ping-pong buffers on KGIcon are here!

Jon M. Taylor wrote:
> 
>         Well, I have some cleanups to do tomorrow before I commit to CVS, but
> it all works now.  You mmap() /proc/kgi/kgicommand 

I'm just back from vacation and haven't had time to look at the code
yet, but how does /proc/kgi/kgicommand and /proc/kgi/gc work with
multihead? Shouldn't there be one file for each head?

Also, remember that LibGGI is in beta. Don't just break things without
discussion like with the genkgi sublib. Please add code so it will
still work with KGIcon drivers that use the older "hacky" GC-mapping.

And _please_ write code that cleans up after itself:

        fd_gc = open("/proc/kgi/gc", O_RDWR);
        if (fd_gc == -1)
        {
                return GGI_DL_ERROR;
        }
        
        priv = malloc(sizeof(struct genkgi_priv));
        if (priv == NULL) {
==> missing close()
                return GGI_DL_ERROR;
        }

        if ((priv->mapped_gc = (ggi_gc *) mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd_gc, 
0))
            == MAP_FAILED) {
                free(priv);
==> missing close()
                return GGI_DL_ERROR;
        }
<snip>

int GGIdlcleanup(ggi_visual *vis)
{
        munmap((void*) GENKGI_PRIV(vis)->mapped_gc, 4096);

        GGIDPRINT_MISC("gengki: Unmapped GC\n");
        
        free(GENKGI_PRIV(vis));
==> missing close()
        GENKGI_PRIV(vis) = NULL;


On a related note the procfs code in KGIcon does not
* check the return code from vmalloc()
* check the return code from proc_register()
* use vfree() and proc_unregister() when the module is unloaded.
and it isn't surrounded by #ifdef CONFIG_PROC_FS

You are doing a great job on KGIcon as well as MesaGGI, so I'm a little
surprised that you make these mistakes...

Just remember - everyone!
Always check your return codes.
Always free what you have allocated.

//Marcus
-- 
-------------------------------+------------------------------------
        Marcus Sundberg        | http://www.stacken.kth.se/~mackan
 Royal Institute of Technology |       Phone: +46 707 295404
       Stockholm, Sweden       |   E-Mail: mackan@stacken.kth.se

Index: [thread] [date] [subject] [author]