git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Linus Torvalds <torvalds@osdl.org>
To: Junio C Hamano <junkio@cox.net>, Timo Hirvonen <tihirvon@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: What's in git.git
Date: Sun, 25 Jun 2006 10:47:10 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0606251033030.3747@g5.osdl.org> (raw)
In-Reply-To: <7v7j35wp84.fsf@assigned-by-dhcp.cox.net>



On Sun, 25 Jun 2006, Junio C Hamano wrote:
> 
>    Timo Hirvonen:
>       Clean up diff.c

THIS IS CRAP!

Dammit, anybody who claims that casting a constant string to "(char *)" is 
a _cleanup_ is doing something seriously wrong.

That's crap, crap, crap, CRAP!

If the "cleanup" was about hiding compiler warnings, then dammit, those 
warnings should be fixed by fixing the code, not by casting the warning 
away but leaving the broken code.

If the ptr really is never accessed, and doesn't matter, then don't use a 
constant empty string, use NULL.

And if it _is_ accessed, then casting a constant string to "char *" is 
_wrong_. 

The whole and only point about the "const" warnings is not to hide them, 
but to fix the code. If you're not going to fix the code, then you 
shouldn't ask the compiler to warn about it, it's that simple. Adding 
bogus casts is not the answer.

I really hate how many _bogus_ casts we're growing. Casts are one of the 
most important features of C (it's what allows you to break the type 
system if you need to, and turns C into the truly extensible language it 
is), but they should be used with reverence and care, not to shut up a 
compiler.

I'm _especially_ disgusted by how this was claimed to be a "cleanup". 
Adding a cast is _never_ a cleanup.

Dammit, don't do crap like this!

THIS is a cleanup:

-               char *prefix = "";
+               const char *prefix = "";

but THESE are total and utter CRAP:

-               mf->ptr = ""; /* does not matter */
+               mf->ptr = (char *)""; /* does not matter */
-                               s->data = "";
+                               s->data = (char *)"";

and we're better off with the warning than with the new code.

I suspect that both could have been made to use NULL instead to indicate 
that no pointer exists.

			Linus

  reply	other threads:[~2006-06-25 17:47 UTC|newest]

Thread overview: 240+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-25  9:37 What's in git.git Junio C Hamano
2006-06-25 17:47 ` Linus Torvalds [this message]
2006-06-25 18:07   ` Timo Hirvonen
2006-06-25 18:43     ` Linus Torvalds
2006-06-27  5:54   ` Junio C Hamano
2006-06-27  6:29     ` Linus Torvalds
2006-06-27  7:55       ` Johannes Schindelin
2006-06-26 22:24 ` Martin Langhoff
  -- strict thread matches above, loose matches on Subject: below --
2008-01-30  8:32 What's in git.git (stable frozen) Junio C Hamano
2008-02-12  7:25 ` What's in git.git Junio C Hamano
2008-02-12  9:15   ` Daniel Stenberg
2008-02-12  9:47     ` Mike Hommey
2008-02-12 11:35       ` Daniel Stenberg
2007-05-13 22:30 What's in git.git (stable) Junio C Hamano
2007-05-17  0:21 ` Junio C Hamano
2007-05-19  5:24   ` Junio C Hamano
2007-05-23 21:46     ` Junio C Hamano
2007-05-29 10:12       ` Junio C Hamano
2007-06-02 21:09         ` Junio C Hamano
2007-06-07  2:08           ` Junio C Hamano
2007-06-13 20:11             ` Junio C Hamano
2007-06-21  7:21               ` Junio C Hamano
2007-06-25  9:43                 ` Junio C Hamano
2007-07-02  0:16                   ` Junio C Hamano
2007-07-13  6:06                     ` What's in git.git Junio C Hamano
2006-11-25 10:12 Junio C Hamano
2006-11-28 19:23 ` Carl Worth
2006-11-29 10:21   ` Johannes Schindelin
2006-11-23  2:49 Junio C Hamano
2006-11-18 22:24 Junio C Hamano
2006-11-18 23:14 ` Junio C Hamano
2006-11-19 15:17   ` Johannes Schindelin
2006-11-19 15:45     ` Jakub Narebski
2006-11-19 16:30       ` Johannes Schindelin
2006-11-19 18:31         ` Jakub Narebski
2006-11-19 19:06           ` Johannes Schindelin
2006-11-19 17:01     ` Petr Baudis
2006-11-12  6:07 Junio C Hamano
2006-11-08  3:21 Junio C Hamano
2006-11-08  4:13 ` David Lang
2006-11-09  2:28   ` Horst H. von Brand
2006-11-09  2:54     ` Junio C Hamano
2006-11-09  3:04       ` Junio C Hamano
2006-11-09  3:45       ` Dave Dillow
2006-11-12 22:25   ` Johannes Schindelin
2006-11-08  7:40 ` Jakub Narebski
2006-11-08  7:59   ` Junio C Hamano
2006-11-08  7:58 ` Jakub Narebski
2006-11-08  8:26   ` Junio C Hamano
2006-11-08 14:51 ` Petr Baudis
2006-11-09  0:02 ` Junio C Hamano
2006-11-02  0:53 Junio C Hamano
2006-11-02 10:02 ` Johannes Schindelin
2006-11-05 17:24 ` Rene Scharfe
2006-11-05 18:47   ` Junio C Hamano
2006-10-26  8:47 Junio C Hamano
2006-10-26  9:12 ` Jakub Narebski
2006-10-26  9:24   ` Junio C Hamano
2006-10-26 12:08   ` Petr Baudis
2006-10-26 12:17     ` Jakub Narebski
2006-10-26  9:19 ` Jakub Narebski
2006-10-27  1:10   ` Petr Baudis
2006-10-26 12:22 ` Petr Baudis
2006-10-26 17:27 ` Andy Whitcroft
2006-10-24  6:32 Junio C Hamano
2006-10-19  5:58 Junio C Hamano
2006-10-17  7:44 Junio C Hamano
2006-10-17 17:16 ` Linus Torvalds
2006-10-17 18:15   ` Davide Libenzi
2006-10-17 18:19   ` Junio C Hamano
2006-10-17 18:53     ` Linus Torvalds
2006-10-17 18:57     ` Andy Whitcroft
2006-10-06  0:59 Junio C Hamano
2006-09-28  7:39 Junio C Hamano
2006-09-28  9:36 ` Petr Baudis
2006-09-28 13:27   ` Johannes Schindelin
2006-09-29  7:34   ` Junio C Hamano
2006-09-29  8:32     ` Petr Baudis
2006-09-30  7:31       ` Junio C Hamano
2006-09-29  8:09   ` Junio C Hamano
2006-09-11  2:21 Junio C Hamano
2006-09-11 11:29 ` Jakub Narebski
2006-09-11 16:31   ` Junio C Hamano
2006-09-11 21:06     ` Jakub Narebski
2006-09-11 22:14       ` Petr Baudis
2006-09-11 23:48         ` Junio C Hamano
2006-09-18  5:33 ` Junio C Hamano
2006-09-18  5:39   ` Jakub Narebski
2006-09-18  5:50     ` Junio C Hamano
2006-09-18  6:07       ` Jakub Narebski
2006-09-18  8:11         ` Johannes Schindelin
2006-09-18  8:19           ` Junio C Hamano
2006-09-18  5:48   ` Jakub Narebski
2006-09-18 14:23   ` Franck Bui-Huu
2006-09-24 10:37   ` Junio C Hamano
2006-08-28  7:19 Junio C Hamano
2006-08-17  6:45 Junio C Hamano
2006-08-14  2:30 Junio C Hamano
2006-08-14  8:11 ` Alex Riesen
2006-08-04 10:12 Junio C Hamano
2006-08-04 10:27 ` Jakub Narebski
2006-08-04 18:40 ` Johannes Schindelin
2006-08-04 18:55 ` Jakub Narebski
2006-08-04 19:09   ` Junio C Hamano
2006-08-04 19:50     ` Junio C Hamano
2006-08-04 20:06       ` Junio C Hamano
2006-08-04 20:27       ` Jakub Narebski
2006-08-01 23:54 Junio C Hamano
2006-08-02  0:34 ` Johannes Schindelin
2006-08-02  7:41   ` Junio C Hamano
2006-08-02 14:02 ` Alex Riesen
2006-08-03  4:56   ` Junio C Hamano
2006-08-03  8:09     ` Alex Riesen
2006-08-03  9:16       ` Junio C Hamano
2006-08-03 12:32         ` Alex Riesen
2006-08-03 12:35           ` Alex Riesen
2006-08-02 19:29 ` carbonated beverage
2006-08-03  4:52   ` Junio C Hamano
2006-08-03  5:15     ` A Large Angry SCM
2006-08-03  5:30     ` carbonated beverage
2006-08-03  5:48       ` carbonated beverage
2006-08-03  7:36         ` carbonated beverage
2006-08-03  7:37           ` carbonated beverage
2006-08-03  8:39           ` Junio C Hamano
2006-08-03  8:50             ` carbonated beverage
2006-08-03  9:31               ` carbonated beverage
2006-08-03  9:03             ` Jakub Narebski
2006-07-17  8:29 Junio C Hamano
2006-07-08  0:37 Junio C Hamano
2006-07-08  2:28 ` Johannes Schindelin
2006-07-08 21:28 ` Jakub Narebski
2006-07-02  7:45 Junio C Hamano
2006-06-29  6:41 Junio C Hamano
2006-06-18  0:48 Junio C Hamano
2006-06-18 12:26 ` Johannes Schindelin
2006-06-18 13:08   ` Petr Baudis
2006-06-18 18:43     ` Johannes Schindelin
2006-06-19  7:34     ` Junio C Hamano
2006-06-19  8:35       ` Johannes Schindelin
2006-05-29  6:44 Junio C Hamano
2006-05-24 22:40 Junio C Hamano
2006-05-21 19:01 Junio C Hamano
2006-05-16  5:30 Junio C Hamano
2006-05-10  3:11 Junio C Hamano
2006-05-10  3:48 ` Linus Torvalds
2006-05-10  4:21 ` Linus Torvalds
2006-05-10  4:26   ` Linus Torvalds
2006-05-10  4:41   ` Junio C Hamano
2006-05-10  4:51     ` Linus Torvalds
2006-05-10  4:36 ` Randal L. Schwartz
2006-05-10  4:45   ` Linus Torvalds
2006-05-10 14:15     ` Nicolas Pitre
2006-05-10 15:00       ` Alex Riesen
2006-05-10 16:48       ` Linus Torvalds
2006-05-10  5:05   ` Junio C Hamano
2006-05-10  5:34 ` Martin Langhoff
2006-05-10  6:48 ` Jakub Narebski
2006-05-04  8:14 Junio C Hamano
2006-05-04  9:06 ` Petr Baudis
2006-05-03 18:54 Junio C Hamano
2006-04-26 11:09 Junio C Hamano
2006-04-22  0:52 Junio C Hamano
2006-04-22 11:25 ` Johannes Schindelin
2006-04-14  7:49 Junio C Hamano
2006-04-18  8:44 ` Junio C Hamano
2006-04-11  4:40 Junio C Hamano
2006-04-11 13:50 ` Linus Torvalds
2006-04-11 15:55   ` Petr Baudis
2006-04-11 17:58     ` Junio C Hamano
2006-04-04 23:06 Junio C Hamano
2006-03-28  0:28 Junio C Hamano
2006-03-26  6:00 Junio C Hamano
2006-03-22  1:58 Junio C Hamano
2006-03-22  2:18 ` Randal L. Schwartz
2006-03-22  3:26   ` Randal L. Schwartz
2006-03-22  5:07     ` Junio C Hamano
2006-03-22  5:35       ` Randal L. Schwartz
2006-03-22  5:46         ` Junio C Hamano
2006-03-22 16:21           ` Linus Torvalds
2006-03-22 10:21 ` Bertrand Jacquin
2006-03-22 11:52 ` Petr Baudis
2006-03-22 19:15   ` Junio C Hamano
2006-03-15 22:13 Junio C Hamano
2006-03-07 22:23 Francis Daly
2006-03-06  7:13 Junio C Hamano
2006-03-06  9:05 ` Martin Langhoff
2006-03-10 10:44   ` Fredrik Kuivinen
2006-03-10 11:17     ` Johannes Schindelin
2006-03-10 11:59       ` Martin Langhoff
2006-03-13  5:01     ` Junio C Hamano
2006-03-06  9:15 ` Johannes Schindelin
2006-03-06 10:29 ` Lukas Sandström
2006-03-05  4:22 Junio C Hamano
2006-03-05  4:51 ` Junio C Hamano
2006-03-05  4:58 ` Linus Torvalds
2006-03-05  5:44   ` Junio C Hamano
2006-03-05 17:53     ` Linus Torvalds
2006-03-05 18:29       ` Linus Torvalds
2006-03-05 19:36         ` Junio C Hamano
2006-03-05 20:04           ` Linus Torvalds
2006-03-05 19:53         ` Junio C Hamano
2006-03-05  9:21 ` Martin Langhoff
2006-03-05  9:58   ` Alexandre Julliard
2006-03-05 10:15     ` Martin Langhoff
2006-03-05 10:47       ` Alexandre Julliard
2006-03-05 10:10   ` Junio C Hamano
2006-03-01 12:24 Junio C Hamano
2006-03-01 21:28 ` Nicolas Pitre
2006-03-01 22:51   ` Junio C Hamano
2006-03-01 23:01 ` Luck, Tony
2006-02-23  2:05 Junio C Hamano
2006-02-22 10:45 Junio C Hamano
2006-02-22 13:46 ` Alex Riesen
2006-02-20  7:57 Junio C Hamano
2006-02-20  8:34 ` Andreas Ericsson
2006-02-20  9:04   ` Junio C Hamano
2006-02-20  9:47   ` Junio C Hamano
2006-02-19  8:56 Junio C Hamano
2006-02-17 14:28 linux
2006-02-18  6:49 ` Junio C Hamano
2006-02-16  6:57 Junio C Hamano
2006-02-10 17:03 Luck, Tony
2006-02-09 23:49 Luck, Tony
2006-02-10  0:28 ` Junio C Hamano
2006-02-10  0:35   ` Junio C Hamano
2006-02-14 23:10     ` Luck, Tony
2006-02-10  0:40 ` Ryan Anderson
2006-02-10  0:46   ` Junio C Hamano
2006-02-09  6:47 Junio C Hamano
     [not found] ` <20060209030905.319f2e48.seanlkml@sympatico.ca>
2006-02-09  8:09   ` sean
2006-02-09  9:04     ` Andreas Ericsson
     [not found]       ` <20060209044039.45763d4f.seanlkml@sympatico.ca>
2006-02-09  9:40         ` sean
2006-02-09  9:55       ` Junio C Hamano
2006-02-09 10:29         ` Andreas Ericsson
2006-02-09 10:55           ` Junio C Hamano
2006-02-09 11:35             ` Andreas Ericsson
2006-02-10  0:47               ` Junio C Hamano
2006-02-09  9:58 ` Johannes Schindelin
2006-02-09 10:32   ` Junio C Hamano
2006-02-09 11:24     ` Johannes Schindelin
2006-02-09 23:14 ` Tony Luck
2006-02-09 23:30   ` Ryan Anderson
2006-02-09 23:44   ` Junio C Hamano
2006-02-10 15:02   ` Junio C Hamano
2006-01-28 21:08 Junio C Hamano
2006-01-25 13:00 Junio C Hamano
     [not found] ` <8aa486160601250741k120f0021h@mail.gmail.com>
2006-01-25 19:24   ` Junio C Hamano
2006-01-25 20:36 ` Jason Riedy
     [not found] ` <8aa486160601250634v294857e0j@mail.gmail.com>
2006-01-25 23:56   ` Junio C Hamano
     [not found]     ` <8aa486160601260104v745594d9m@mail.gmail.com>
     [not found]       ` <7vk6cngwfh.fsf@assigned-by-dhcp.cox.net>
     [not found]         ` <8aa486160601260156h6157ca34s@mail.gmail.com>
2006-01-26 12:12           ` Junio C Hamano
2006-01-26 16:24             ` Santi Bejar
2006-01-20  8:42 Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0606251033030.3747@g5.osdl.org \
    --to=torvalds@osdl.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    --cc=tihirvon@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).