Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756052Ab2JZDit (ORCPT ); Thu, 25 Oct 2012 23:38:49 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:53299 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755886Ab2JZDir (ORCPT ); Thu, 25 Oct 2012 23:38:47 -0400 MIME-Version: 1.0 In-Reply-To: References: <1351212379-26026-1-git-send-email-ming.lei@canonical.com> From: Linus Torvalds Date: Thu, 25 Oct 2012 20:38:25 -0700 X-Google-Sender-Auth: fVWJEsfShY4niplJrCRlzwiYbLM Message-ID: Subject: Re: [PATCH v1] firmware loader: introduce module parameter to customize fw search path To: Ming Lei Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1492 Lines: 38 On Thu, Oct 25, 2012 at 8:12 PM, Ming Lei wrote: > > Yes, it should be the cleanest, I don't do it because I thought that might > have caused one compile warning('const char *' points to memory > without 'const', like below) You can just keep the const. In fact, you could even add one, and make it be static const char * const fw_path[] = { We currently don't mark fw_path[] itself const (even though it is), only the strings it points to. > but in fact there isn't any warning with above change and it does work, still > don't know why? :-( It's valid to cast a non-const pointer to a const one. It's the *other* way around that is invalid. So marking fw_path[] as having 'const char *' elements just means that we won't be changing those elements through the fw_path[] array (correct: we only read them). The fact that one of those same pointers is then also available through a non-const pointer variable means that they can change through *that* pointer, but that doesn't change the fact that fw_path[] itself contains const pointers. Remember: in C, a "const pointer" does *not* mean that the thing it points to cannot change. It only means that it cannot change through *that* pointer. Linus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/