From patchwork Thu Jun 4 07:12:01 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ludwig Nussel X-Patchwork-Id: 12736 Received: from cantor2.suse.de ([195.135.220.15] helo=mx2.suse.de) by mail.linuxtv.org with esmtp (Exim 4.63) (envelope-from ) id 1MC77h-0006Ux-Hj for vdr@linuxtv.org; Thu, 04 Jun 2009 09:12:26 +0200 Received: from relay1.suse.de (mail2.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id B38695FC9F for ; Thu, 4 Jun 2009 09:12:21 +0200 (CEST) From: Ludwig Nussel To: vdr@linuxtv.org Date: Thu, 4 Jun 2009 09:12:01 +0200 User-Agent: KMail/1.11.2 (Linux/2.6.27.21-0.1-default; KDE/4.2.2; x86_64; ; ) References: <200902272124.38328.ville.skytta@iki.fi> <200904142312.16137.ville.skytta@iki.fi> In-Reply-To: <200904142312.16137.ville.skytta@iki.fi> MIME-Version: 1.0 Message-Id: <200906040912.01927.ludwig.nussel@suse.de> X-LSpam-Score: -7.6 (-------) X-LSpam-Report: No, score=-7.6 required=5.0 tests=AWL=-1.000, BAYES_00=-2.599, RCVD_IN_DNSWL_MED=-4 autolearn=ham Subject: Re: [vdr] Build failures with gcc 4.4 X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.9 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jun 2009 07:15:32 -0000 Status: O X-Status: X-Keywords: X-UID: 20709 Ville Skyttä wrote: > On Friday 27 February 2009, Ville Skyttä wrote: > > I'm trying to build VDR 1.6.0-2 for the upcoming Fedora 11 release which > > has gcc 4.4. There are a bunch of compilation errors as gcc has again > > become less forgiving for C++ than it used to be. > > > > One very common source of problems is explained here: > > http://markmail.org/message/e5y6atneqztuvpw6#query: > > +page:1+mid:hdkehz7bgl5b6vgc+state:results > > > > There are quite a few of these problems in VDR 1.6.0-2 ("error: invalid > > conversion from 'const char*' to 'char*'"). I started patching but quickly > > realized that this is a job for someone who actually knows what he's doing. > [...] > > ...but until there's a real fix available, the attached ugly patch at least > makes the build succeed with gcc 4.4. So gcc 4.4 finally hit openSUSE as well. I use the attached patch to make vdr compile. Seems to work fine too. The code that requires those const casts is really ugly though. cu Ludwig Index: vdr-1.6.0/recording.c =================================================================== --- vdr-1.6.0.orig/recording.c +++ vdr-1.6.0/recording.c @@ -509,8 +509,8 @@ cRecording::cRecording(cTimer *Timer, co Utf8Strn0Cpy(SubtitleBuffer, Subtitle, MAX_SUBTITLE_LENGTH); Subtitle = SubtitleBuffer; } - char *macroTITLE = strstr(Timer->File(), TIMERMACRO_TITLE); - char *macroEPISODE = strstr(Timer->File(), TIMERMACRO_EPISODE); + const char *macroTITLE = strstr(Timer->File(), TIMERMACRO_TITLE); + const char *macroEPISODE = strstr(Timer->File(), TIMERMACRO_EPISODE); if (macroTITLE || macroEPISODE) { name = strdup(Timer->File()); name = strreplace(name, TIMERMACRO_TITLE, Title); @@ -551,7 +551,7 @@ cRecording::cRecording(const char *FileN sortBuffer = NULL; fileName = strdup(FileName); FileName += strlen(VideoDirectory) + 1; - char *p = strrchr(FileName, '/'); + const char *p = strrchr(FileName, '/'); name = NULL; info = new cRecordingInfo; @@ -1022,7 +1022,8 @@ void cRecordings::DelByName(const char * if (recording) { cThreadLock DeletedRecordingsLock(&DeletedRecordings); Del(recording, false); - char *ext = strrchr(recording->FileName(), '.'); + // wtf? + char *ext = strrchr(const_cast(recording->FileName()), '.'); if (ext) { strncpy(ext, DELEXT, strlen(ext)); recording->fileSizeMB = DirSizeMB(recording->FileName()); Index: vdr-1.6.0/svdrp.c =================================================================== --- vdr-1.6.0.orig/svdrp.c +++ vdr-1.6.0/svdrp.c @@ -736,7 +736,7 @@ void cSVDRP::CmdGRAB(const char *Option) char *strtok_next; FileName = strtok_r(p, delim, &strtok_next); // image type: - char *Extension = strrchr(FileName, '.'); + const char *Extension = strrchr(FileName, '.'); if (Extension) { if (strcasecmp(Extension, ".jpg") == 0 || strcasecmp(Extension, ".jpeg") == 0) Jpeg = true; @@ -796,12 +796,12 @@ void cSVDRP::CmdGRAB(const char *Option) if (FileName) { if (grabImageDir) { cString s; - char *slash = strrchr(FileName, '/'); + char *slash = strrchr(const_cast(FileName), '/'); if (!slash) { s = AddDirectory(grabImageDir, FileName); FileName = s; } - slash = strrchr(FileName, '/'); // there definitely is one + slash = strrchr(const_cast(FileName), '/'); // there definitely is one *slash = 0; char *r = realpath(FileName, RealFileName); *slash = '/';